Package org.syncany.operations.watch
Class DefaultRecursiveWatcher
- java.lang.Object
-
- org.syncany.operations.watch.RecursiveWatcher
-
- org.syncany.operations.watch.DefaultRecursiveWatcher
-
public class DefaultRecursiveWatcher extends RecursiveWatcher
The default recursive file watcher monitors a folder (and its sub-folders) by registering a watch on each of the sub-folders. This class is used on Linux/Unix-based operating systems and uses the Java 7WatchService.The class walks through the file tree and registers to a watch to every sub-folder. For new folders, a new watch is registered, and stale watches are removed.
When a file event occurs, a timer is started to wait for the file operations to settle. It is reset whenever a new event occurs. When the timer times out, an event is thrown through the
RecursiveWatcher.WatchListener.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.syncany.operations.watch.RecursiveWatcher
RecursiveWatcher.WatchListener
-
-
Field Summary
-
Fields inherited from class org.syncany.operations.watch.RecursiveWatcher
ignorePaths, logger, root
-
-
Constructor Summary
Constructors Constructor Description DefaultRecursiveWatcher(java.nio.file.Path root, java.util.List<java.nio.file.Path> ignorePaths, int settleDelay, RecursiveWatcher.WatchListener listener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterStop()Called after theRecursiveWatcher.stop()method.protected voidbeforePollEventLoop()Called in the watch service polling thread, right before theRecursiveWatcher.pollEvents()loop.voidbeforeStart()Called before theRecursiveWatcher.start()method.protected booleanpollEvents()Called in the watch service polling thread, inside of theRecursiveWatcher.pollEvents()loop.protected voidwatchEventsOccurred()Called in the watch service polling thread, whenever a file system event occurs.-
Methods inherited from class org.syncany.operations.watch.RecursiveWatcher
createRecursiveWatcher, start, stop
-
-
-
-
Constructor Detail
-
DefaultRecursiveWatcher
public DefaultRecursiveWatcher(java.nio.file.Path root, java.util.List<java.nio.file.Path> ignorePaths, int settleDelay, RecursiveWatcher.WatchListener listener)
-
-
Method Detail
-
beforeStart
public void beforeStart() throws java.lang.Exception
Description copied from class:RecursiveWatcherCalled before theRecursiveWatcher.start()method. This method is only called once.- Specified by:
beforeStartin classRecursiveWatcher- Throws:
java.lang.Exception
-
beforePollEventLoop
protected void beforePollEventLoop()
Description copied from class:RecursiveWatcherCalled in the watch service polling thread, right before theRecursiveWatcher.pollEvents()loop. This method is only called once.- Specified by:
beforePollEventLoopin classRecursiveWatcher
-
pollEvents
protected boolean pollEvents() throws java.lang.InterruptedException
Description copied from class:RecursiveWatcherCalled in the watch service polling thread, inside of theRecursiveWatcher.pollEvents()loop. This method is called multiple times.- Specified by:
pollEventsin classRecursiveWatcher- Throws:
java.lang.InterruptedException
-
watchEventsOccurred
protected void watchEventsOccurred()
Description copied from class:RecursiveWatcherCalled in the watch service polling thread, whenever a file system event occurs. This may be used by subclasses to (re-)set watches on folders. This method is called multiple times.- Specified by:
watchEventsOccurredin classRecursiveWatcher
-
afterStop
public void afterStop() throws java.io.IOException
Description copied from class:RecursiveWatcherCalled after theRecursiveWatcher.stop()method. This method is only called once.- Specified by:
afterStopin classRecursiveWatcher- Throws:
java.io.IOException
-
-