Class AbstractFileWatcher
java.lang.Object
me.lucko.luckperms.common.storage.implementation.file.watcher.AbstractFileWatcher
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
FileWatcher
Utility for "watching" for file changes using a
WatchService.-
Constructor Summary
ConstructorsConstructorDescriptionAbstractFileWatcher(FileSystem fileSystem, boolean autoRegisterNewSubDirectories) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected abstract voidprocessEvent(WatchEvent<Path> event, Path path) Process an observed watch event.voidRegister a watch key in the given directory.voidregisterRecursively(Path root) Register a watch key recursively in the given directory.final voidProcessesWatchEvents from the watch service until it is closed, or until the thread is interrupted.
-
Constructor Details
-
AbstractFileWatcher
public AbstractFileWatcher(FileSystem fileSystem, boolean autoRegisterNewSubDirectories) throws IOException - Throws:
IOException
-
-
Method Details
-
register
Register a watch key in the given directory.- Parameters:
directory- the directory- Throws:
IOException- if unable to register a key
-
registerRecursively
Register a watch key recursively in the given directory.- Parameters:
root- the root directory- Throws:
IOException- if unable to register a key
-
processEvent
Process an observed watch event.- Parameters:
event- the eventpath- the resolved event context
-
runEventProcessingLoop
public final void runEventProcessingLoop()ProcessesWatchEvents from the watch service until it is closed, or until the thread is interrupted. -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-