public class DirectoryWatcher extends Object implements Runnable
DirectoryWatcher
covers implementation of the low level WatchService API.
Highly inspired by http://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java Since java.nio.file.Watch* is not guaranteed to be using native events, we'll probably want to extract an interface for this. (non-native implementations use polling and can be quite slow) JDK on OSX doesn't have a native impl for 7 or 8: https://bugs.openjdk.java.net/browse/JDK-7133447 See http://wiki.netbeans.org/NativeFileNotifications https://code.google.com/p/barbarywatchservice/
Constructor and Description |
---|
DirectoryWatcher(boolean recursive,
boolean followLinks)
Deprecated.
Since 5.4.5, Please use
DirectoryWatcher(boolean, boolean, MagnoliaConfigurationProperties) instead. |
DirectoryWatcher(boolean recursive,
boolean followLinks,
info.magnolia.init.MagnoliaConfigurationProperties properties) |
Modifier and Type | Method and Description |
---|---|
protected WatchEvent.Modifier[] |
getWatchEventModifiers(WatchService watchService) |
protected void |
processEvent(WatchEvent.Kind<?> kind,
Path completePath,
WatchEvent<?> watchEvent)
Process given pending
WatchEvent as needed. |
void |
register(Path dir,
com.google.common.base.Predicate<Path> filterPredicate,
WatcherCallback callback) |
protected void |
registerDirectory(Path dir)
Register the given directory with the WatchService.
|
protected void |
registerRecursively(Path start,
com.google.common.base.Predicate<Path> filterPredicate)
Register the given directory, and all its sub-directories, with the WatchService.
|
void |
run() |
public DirectoryWatcher(boolean recursive, boolean followLinks, info.magnolia.init.MagnoliaConfigurationProperties properties) throws IOException
IOException
@Deprecated public DirectoryWatcher(boolean recursive, boolean followLinks) throws IOException
DirectoryWatcher(boolean, boolean, MagnoliaConfigurationProperties)
instead.IOException
public void register(Path dir, com.google.common.base.Predicate<Path> filterPredicate, WatcherCallback callback) throws IOException
IOException
protected void registerDirectory(Path dir) throws IOException
IOException
protected WatchEvent.Modifier[] getWatchEventModifiers(WatchService watchService)
protected void registerRecursively(Path start, com.google.common.base.Predicate<Path> filterPredicate) throws IOException
IOException
protected void processEvent(WatchEvent.Kind<?> kind, Path completePath, WatchEvent<?> watchEvent)
WatchEvent
as needed.kind
- the event kind
completePath
- an absolute Path
where the event occurredwatchEvent
- the raw event for further custom processingCopyright © 2003–2016 Magnolia International Ltd.. All rights reserved.