Package com.swoval.files
Class PathWatchers
- java.lang.Object
-
- com.swoval.files.PathWatchers
-
public class PathWatchers extends java.lang.ObjectProvides factory methods to create instances ofPathWatcher. It also defines thePathWatchers.Eventclass for which thePathWatcherwill emit events.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPathWatchers.EventContainer forPathWatcherevents.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PathWatcher<PathWatchers.Event>get(boolean followLinks)Create a PathWatcher for the runtime platform.static PathWatcher<PathWatchers.Event>polling(boolean followLinks, long pollInterval, java.util.concurrent.TimeUnit timeUnit)Create a path watcher that periodically polls the file system to detect changesstatic PathWatcher<PathWatchers.Event>polling(FileTreeDataViews.Converter<java.lang.Long> converter, boolean followLinks, long pollInterval, java.util.concurrent.TimeUnit timeUnit)Create a path watcher that periodically polls the file system to detect changes
-
-
-
Method Detail
-
get
public static PathWatcher<PathWatchers.Event> get(boolean followLinks) throws java.io.IOException, java.lang.InterruptedException
Create a PathWatcher for the runtime platform.- Parameters:
followLinks- toggles whether or not the targets of symbolic links should be monitored- Returns:
- PathWatcher for the runtime platform
- Throws:
java.io.IOException- when the underlyingWatchServicecannot be initializedjava.lang.InterruptedException- when thePathWatcheris interrupted during initialization
-
polling
public static PathWatcher<PathWatchers.Event> polling(FileTreeDataViews.Converter<java.lang.Long> converter, boolean followLinks, long pollInterval, java.util.concurrent.TimeUnit timeUnit) throws java.lang.InterruptedException
Create a path watcher that periodically polls the file system to detect changes- Parameters:
converter- calculates the last modified time in milliseconds for the path watcher. This exists so that the converter can be replaced with a higher resolution calculation of the file system last modified time than is provided by the jvm, e.g. sbt.IO.getLastModifiedTimeOrZero.followLinks- toggles whether or not the targets of symbolic links should be monitoredpollInterval- minimum duration between when polling ends and the next poll beginstimeUnit- the time unit for which the pollInterval corresponds- Returns:
- the polling path watcher.
- Throws:
java.lang.InterruptedException- if the polling thread cannot be started.
-
polling
public static PathWatcher<PathWatchers.Event> polling(boolean followLinks, long pollInterval, java.util.concurrent.TimeUnit timeUnit) throws java.lang.InterruptedException
Create a path watcher that periodically polls the file system to detect changes- Parameters:
followLinks- toggles whether or not the targets of symbolic links should be monitoredpollInterval- minimum duration between when polling ends and the next poll beginstimeUnit- the time unit for which the pollInterval corresponds- Returns:
- the polling path watcher.
- Throws:
java.lang.InterruptedException- if the polling thread cannot be started.
-
-