Package org.syncany.operations.watch
Class WindowsRecursiveWatcher
- java.lang.Object
-
- org.syncany.operations.watch.RecursiveWatcher
-
- org.syncany.operations.watch.WindowsRecursiveWatcher
-
public class WindowsRecursiveWatcher extends RecursiveWatcher
The Windows recursive file watcher monitors a folder (and its sub-folders) by registering a recursive watch on the root folder. This class is used only on Windows and uses jpathwatch-basedWatchService.Via the jpathwatch library, the class uses the Windows-native recursive folder- watching capabilities of Windows and thereby does not need to register watches on all sub-folders. Instead, only one watch on the root folder is needed.
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 WindowsRecursiveWatcher(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.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
-
WindowsRecursiveWatcher
public WindowsRecursiveWatcher(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
public 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
-
-