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 TypeMethodDescriptionvoid
register
(OnFileChangeListener listener, String dirPath, String... globPatterns) Notifies the implementation of this interface thatdirPath
should be monitored for file system events.void
start()
Starts the service.void
unregister
(OnFileChangeListener listener) Notifies the implementation of this interface thatlistener
should cease to be notified of file system events.void
Unregisters all listeners.
-
Method Details
-
start
void start()Description copied from interface:Service
Starts 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 thatdirPath
should be monitored for file system events. If the changed file matches any of theglobPatterns
,listener
should 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
- IfdirPath
is not a directory.
-
unregister
Notifies the implementation of this interface thatlistener
should cease to be notified of file system events.- Parameters:
listener
- Listener to unregister. Cannot benull
.
-
unregisterAll
void unregisterAll()Unregisters all listeners.
-