Class DirectoryWatcher


  • public class DirectoryWatcher
    extends java.lang.Object
    • Constructor Detail

      • DirectoryWatcher

        public DirectoryWatcher​(java.util.List<java.nio.file.Path> paths,
                                DirectoryChangeListener listener,
                                java.nio.file.WatchService watchService,
                                FileHasher fileHasher,
                                FileTreeVisitor fileTreeVisitor,
                                org.slf4j.Logger logger)
                         throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • watchAsync

        public java.util.concurrent.CompletableFuture<java.lang.Void> watchAsync()
        Asynchronously watch the directories using ForkJoinPool.commonPool() as the executor
      • watchAsync

        public java.util.concurrent.CompletableFuture<java.lang.Void> watchAsync​(java.util.concurrent.Executor executor)
        Asynchronously watch the directories.
        Parameters:
        executor - the executor to use to watch asynchronously
      • pathHashes

        public java.util.Map<java.nio.file.Path,​FileHash> pathHashes()
      • watch

        public void watch()
        Watch the directories. Block until either the listener stops watching or the DirectoryWatcher is closed.
        Throws:
        java.lang.IllegalStateException - if the directory watcher is closed when watch() is called.
      • close

        public void close()
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • isClosed

        public boolean isClosed()