Interface DirectoryWatchService
- All Superinterfaces:
Service
- All Known Implementing Classes:
SimpleDirectoryWatchService
Interface definition of a simple directory watch service.
Implementations of this interface allow interested parties to
listen to file system events coming from a specific directory.
-
Method Summary
Modifier and TypeMethodDescriptionvoidregister(OnFileChangeListener listener, String dirPath, String... globPatterns) Notifies the implementation of this interface thatdirPathshould be monitored for file system events.voidstart()Starts the service.voidunregister(OnFileChangeListener listener) Notifies the implementation of this interface thatlistenershould cease to be notified of file system events.voidUnregisters all listeners.
-
Method Details
-
start
void start()Description copied from interface:ServiceStarts the service. This method blocks until the service has completely started. -
register
void register(OnFileChangeListener listener, String dirPath, String... globPatterns) throws IOException Notifies the implementation of this interface thatdirPathshould be monitored for file system events. If the changed file matches any of theglobPatterns,listenershould be notified.- Parameters:
listener- The listener.dirPath- The directory path.globPatterns- Zero or more file patterns to be matched against file names. If none provided, matches any file.- Throws:
IOException- IfdirPathis not a directory.
-
unregister
Notifies the implementation of this interface thatlistenershould cease to be notified of file system events.- Parameters:
listener- Listener to unregister. Cannot benull.
-
unregisterAll
void unregisterAll()Unregisters all listeners.
-