Class PathWatchers


  • public class PathWatchers
    extends java.lang.Object
    Provides factory methods to create instances of PathWatcher. It also defines the PathWatchers.Event class for which the PathWatcher will emit events.
    • 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 changes
      static 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 underlying WatchService cannot be initialized
        java.lang.InterruptedException - when the PathWatcher is 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 monitored
        pollInterval - minimum duration between when polling ends and the next poll begins
        timeUnit - 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 monitored
        pollInterval - minimum duration between when polling ends and the next poll begins
        timeUnit - the time unit for which the pollInterval corresponds
        Returns:
        the polling path watcher.
        Throws:
        java.lang.InterruptedException - if the polling thread cannot be started.