Class WatcherService
java.lang.Object
com.activeviam.source.common.api.impl.WatcherService
- All Implemented Interfaces:
IWatcherService
,Closeable
,AutoCloseable
Standard implementation of the watcher service.
- Author:
- ActiveViam
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor, using the file system to have watchers.WatcherService
(WatchService watchService) Full constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Stop the watcher thread.Gets the list of paused watchers.Gets the list of watchers perwatch key
.boolean
isWatcherPaused
(IWatcher watcher) Says if the processing of events for a given watcher is paused.void
pauseWatcher
(IWatcher watcher) Pauses the processing of events for a given watcher.Register a watcher of a path.void
registerAll
(IWatcher watcher, Path path) Register recursively all the directories.void
resumeWatcher
(IWatcher watcher) Resumes the processing of events for a given watcher.void
setFollowSymbolicLinks
(boolean followSymbolicLinks) Sets the flag for following symbolic links.toString()
void
unregister
(IWatcher watcher) Unregisters the given watcher.
-
Constructor Details
-
WatcherService
public WatcherService()Default constructor, using the file system to have watchers. -
WatcherService
Full constructor.- Parameters:
watchService
- watch service to use.
-
-
Method Details
-
registerAll
Description copied from interface:IWatcherService
Register recursively all the directories.- Specified by:
registerAll
in interfaceIWatcherService
- Parameters:
watcher
- the watcherpath
- the directory that may contain other subdirectories
-
register
Description copied from interface:IWatcherService
Register a watcher of a path. When events related to this path are detected by the service, the watcher will be called back.- Specified by:
register
in interfaceIWatcherService
- Parameters:
watcher
- The watcher to register.path
- The path to watch.- Returns:
- the watchKey
-
unregister
Description copied from interface:IWatcherService
Unregisters the given watcher.- Specified by:
unregister
in interfaceIWatcherService
- Parameters:
watcher
- The watcher to unregister from this watcher service.
-
getRegistry
Gets the list of watchers perwatch key
.- Returns:
- The registry
-
setFollowSymbolicLinks
public void setFollowSymbolicLinks(boolean followSymbolicLinks) Sets the flag for following symbolic links.This flag is used when registering a folder to watch. Switching the flag will not impact already registered folders.
- Parameters:
followSymbolicLinks
- true to follow links, false not to.
-
pauseWatcher
Description copied from interface:IWatcherService
Pauses the processing of events for a given watcher.- Specified by:
pauseWatcher
in interfaceIWatcherService
- Parameters:
watcher
- The watcher for which to stop processing events.
-
resumeWatcher
Description copied from interface:IWatcherService
Resumes the processing of events for a given watcher.- Specified by:
resumeWatcher
in interfaceIWatcherService
- Parameters:
watcher
- The watcher for which to resume processing events.
-
isWatcherPaused
Description copied from interface:IWatcherService
Says if the processing of events for a given watcher is paused.- Specified by:
isWatcherPaused
in interfaceIWatcherService
- Parameters:
watcher
- The watcher of which to check the status.- Returns:
true
if the processing of events of the given watcher is paused,false
otherwise.
-
close
Stop the watcher thread.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
toString
-
getPausedTopics
Gets the list of paused watchers.- Returns:
- set of watchers marked as paused.
-