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 void
afterStop()
Called after theRecursiveWatcher.stop()
method.protected void
beforePollEventLoop()
Called in the watch service polling thread, right before theRecursiveWatcher.pollEvents()
loop.void
beforeStart()
Called before theRecursiveWatcher.start()
method.boolean
pollEvents()
Called in the watch service polling thread, inside of theRecursiveWatcher.pollEvents()
loop.protected void
watchEventsOccurred()
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:RecursiveWatcher
Called before theRecursiveWatcher.start()
method. This method is only called once.- Specified by:
beforeStart
in classRecursiveWatcher
- Throws:
java.lang.Exception
-
beforePollEventLoop
protected void beforePollEventLoop()
Description copied from class:RecursiveWatcher
Called in the watch service polling thread, right before theRecursiveWatcher.pollEvents()
loop. This method is only called once.- Specified by:
beforePollEventLoop
in classRecursiveWatcher
-
pollEvents
public boolean pollEvents() throws java.lang.InterruptedException
Description copied from class:RecursiveWatcher
Called in the watch service polling thread, inside of theRecursiveWatcher.pollEvents()
loop. This method is called multiple times.- Specified by:
pollEvents
in classRecursiveWatcher
- Throws:
java.lang.InterruptedException
-
watchEventsOccurred
protected void watchEventsOccurred()
Description copied from class:RecursiveWatcher
Called 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:
watchEventsOccurred
in classRecursiveWatcher
-
afterStop
public void afterStop() throws java.io.IOException
Description copied from class:RecursiveWatcher
Called after theRecursiveWatcher.stop()
method. This method is only called once.- Specified by:
afterStop
in classRecursiveWatcher
- Throws:
java.io.IOException
-
-