001/* 002 * This file is part of McIDAS-V 003 * 004 * Copyright 2007-2016 005 * Space Science and Engineering Center (SSEC) 006 * University of Wisconsin - Madison 007 * 1225 W. Dayton Street, Madison, WI 53706, USA 008 * https://www.ssec.wisc.edu/mcidas 009 * 010 * All Rights Reserved 011 * 012 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and 013 * some McIDAS-V source code is based on IDV and VisAD source code. 014 * 015 * McIDAS-V is free software; you can redistribute it and/or modify 016 * it under the terms of the GNU Lesser Public License as published by 017 * the Free Software Foundation; either version 3 of the License, or 018 * (at your option) any later version. 019 * 020 * McIDAS-V is distributed in the hope that it will be useful, 021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 023 * GNU Lesser Public License for more details. 024 * 025 * You should have received a copy of the GNU Lesser Public License 026 * along with this program. If not, see http://www.gnu.org/licenses. 027 */ 028 029package edu.wisc.ssec.mcidasv.util.pathwatcher; 030 031import java.io.IOException; 032 033// Taken from https://gist.github.com/hindol-viz/394ebc553673e2cd0699 034 035/** 036 * Interface definition of a simple directory watch service. 037 * 038 * Implementations of this interface allow interested parties to 039 * <em>listen</em> to file system events coming from a specific directory. 040 */ 041public interface DirectoryWatchService extends Service { 042 043 @Override void start(); /* Suppress Exception */ 044 045 /** 046 * Notifies the implementation of <em>this</em> interface that 047 * {@code dirPath} should be monitored for file system events. If the 048 * changed file matches any of the {@code globPatterns}, {@code listener} 049 * should be notified. 050 * 051 * @param listener The listener. 052 * @param dirPath The directory path. 053 * @param globPatterns Zero or more file patterns to be matched against 054 * file names. If none provided, matches <em>any</em> 055 * file. 056 * 057 * @throws IOException If {@code dirPath} is not a directory. 058 */ 059 void register(OnFileChangeListener listener, String dirPath, 060 String... globPatterns) 061 throws IOException; 062 063 /** 064 * Notifies the implementation of <em>this</em> interface that 065 * {@code listener} should cease to be notified of file system events. 066 * 067 * @param listener Listener to unregister. Cannot be {@code null}. 068 */ 069 void unregister(OnFileChangeListener listener); 070 071 /** 072 * Unregisters <em>all</em> listeners. 073 */ 074 void unregisterAll(); 075 076}