Package org.openhab.core.service
Interface WatchService
@NonNullByDefault
public interface WatchService
The 
WatchService defines the interface for a general watch service. It allows registering
 listeners for subdirectories of the openHAB configuration directory. The reported path in the event is relative to
 the registered path. Watch services are created by WatchServiceFactory.createWatchService(String, Path).
 For files in the openHAB configuration folder a watch service with the name CONFIG_WATCHER_NAME
 is registered. For convenience, an OSGi target filter for referencing this watch service is provided
 CONFIG_WATCHER_FILTER.- Author:
- Jan N. Klug - Initial contribution
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic enumstatic interface
- 
Field SummaryFields
- 
Method SummaryModifier and TypeMethodDescriptionGet the base directory for thisWatchServicedefault voidregisterListener(WatchService.WatchEventListener watchEventListener, Path path) Register a listener for thisWatchServiceThe given listener will be notified about all events related to files and directories (including subdirectories) in the givenPathdefault voidregisterListener(WatchService.WatchEventListener watchEventListener, Path path, boolean withSubDirectories) Register a listener for thisWatchServiceThe given listener will be notified about all events related to files and directories in the givenPathdefault voidregisterListener(WatchService.WatchEventListener watchEventListener, List<Path> paths) Register a listener for thisWatchServiceThe given listener will be notified about all events related to files and directories (including subdirectories) in the givenPathvoidregisterListener(WatchService.WatchEventListener watchEventListener, List<Path> paths, boolean withSubDirectories) Register a listener for thisWatchServiceThe given listener will be notified about all events related to files and directories in the given list ofPathvoidunregisterListener(WatchService.WatchEventListener watchEventListener) Unregister a listener from thisWatchServiceThe listener will no longer be notified of watch events
- 
Field Details- 
SERVICE_PID- See Also:
 
- 
SERVICE_PROPERTY_DIR- See Also:
 
- 
SERVICE_PROPERTY_NAME- See Also:
 
- 
CONFIG_WATCHER_NAME- See Also:
 
- 
CONFIG_WATCHER_FILTER- See Also:
 
 
- 
- 
Method Details- 
registerListenerRegister a listener for thisWatchServiceThe given listener will be notified about all events related to files and directories (including subdirectories) in the givenPathListeners must unregister themselves before they are disposed- Parameters:
- watchEventListener- the listener for this configuration
- path- a- Paththat the listener is interested in, relative to the base path of the watch service
 
- 
registerListenerRegister a listener for thisWatchServiceThe given listener will be notified about all events related to files and directories (including subdirectories) in the givenPathListeners must unregister themselves before they are disposed- Parameters:
- watchEventListener- the listener for this configuration
- paths- a list of- Paththat the listener is interested in, relative to the base path of the watch service
 
- 
registerListenerdefault void registerListener(WatchService.WatchEventListener watchEventListener, Path path, boolean withSubDirectories) Register a listener for thisWatchServiceThe given listener will be notified about all events related to files and directories in the givenPathListeners must unregister themselves before they are disposed- Parameters:
- watchEventListener- the listener for this configuration
- path- the- Paththat the listener is interested in, relative to the base path of the watch service
- withSubDirectories- whether subdirectories of the given path should also be watched
 
- 
registerListenervoid registerListener(WatchService.WatchEventListener watchEventListener, List<Path> paths, boolean withSubDirectories) Register a listener for thisWatchServiceThe given listener will be notified about all events related to files and directories in the given list ofPathListeners must unregister themselves before they are disposed- Parameters:
- watchEventListener- the listener for this configuration
- paths- a list of- Paththat the listener is interested in, relative to the base path of the watch service
- withSubDirectories- whether subdirectories of the given paths should also be watched
 
- 
unregisterListenerUnregister a listener from thisWatchServiceThe listener will no longer be notified of watch events- Parameters:
- watchEventListener- the listener to unregister
 
- 
getWatchPathPath getWatchPath()Get the base directory for thisWatchService- Returns:
- the Paththat is the base path for all reported events
 
 
-