java.lang.Object
io.helidon.config.FileSystemWatcher
- All Implemented Interfaces:
ChangeWatcher<Path>
This change watcher is backed by
WatchService to fire a polling event with every change on monitored Path.
When a parent directory of the path is not available, or becomes unavailable later, a new attempt to register
WatchService is scheduled again and again until the directory finally exists and the registration is successful.
This ChangeWatcher might be initialized with a custom executor
or the Executors.newSingleThreadScheduledExecutor() is used if none is explicitly configured.
This watcher notifies with appropriate change event in the following cases:
- The watched directory is gone
- The watched directory appears
- A file in the watched directory is deleted, created or modified
A single file system watcher may be used to watch multiple targets. In such a case, if stop() is invoked, it stops
watching all of these targets.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface io.helidon.config.spi.ChangeWatcher
ChangeWatcher.ChangeEvent<T> -
Method Summary
Modifier and TypeMethodDescriptionstatic FileSystemWatcher.Builderbuilder()Fluent API builder forFileSystemWatcher.static FileSystemWatchercreate()Create a new file watcher with default configuration.voidinitWatchServiceModifiers(WatchEvent.Modifier... modifiers) Add modifiers to be used when registering theWatchService.voidstart(Path target, Consumer<ChangeWatcher.ChangeEvent<Path>> listener) Start watching a target for changes.voidstop()Stop watching all targets for changes.type()Target supported by this change watcher.
-
Method Details
-
builder
Fluent API builder forFileSystemWatcher.- Returns:
- a new builder instance
-
create
Create a new file watcher with default configuration.- Returns:
- a new file watcher
-
start
Description copied from interface:ChangeWatcherStart watching a target for changes. If a change happens, notify the listener.- Specified by:
startin interfaceChangeWatcher<Path>- Parameters:
target- target of this watcher, such asPathlistener- listener that handles reloading of the resource being watched
-
stop
public void stop()Description copied from interface:ChangeWatcherStop watching all targets for changes.- Specified by:
stopin interfaceChangeWatcher<Path>
-
type
Description copied from interface:ChangeWatcherTarget supported by this change watcher.- Specified by:
typein interfaceChangeWatcher<Path>- Returns:
- type supported
-
initWatchServiceModifiers
Add modifiers to be used when registering theWatchService. SeePath.register.- Parameters:
modifiers- the modifiers to add
-