Class DirectoryWatcher

java.lang.Object
com.sap.cds.maven.plugin.util.DirectoryWatcher

public class DirectoryWatcher extends Object
Watches a directory, including the sub-tree, for changes on files. With lists of include and exclude GLOB pattern, the watched files can be configured. Only if one of those files has changed, the event listener is notified.
  • Constructor Details

    • DirectoryWatcher

      public DirectoryWatcher(Path root, DirectoryWatcher.FileChangedListener listener, CdsMojoLogger logger, List<String> includes, List<String> excludes)
      Constructs a new DirectoryWatcher instance.
      Parameters:
      root - the root of the directory sub-tree to watch
      listener - the event listener
      logger - the mandatory logger
      includes - an optional list with GLOB patterns describing the files to be include
      excludes - an optional list with GLOB patterns describing the files to be exclude
      Throws:
      NullPointerException - if any of the required arguments is null
  • Method Details

    • start

      public void start() throws IOException
      Starts asynchronously watching for changes on the file system.
      Throws:
      IOException - if registering for watching failed
    • join

      public void join() throws InterruptedException
      Joins the watch thread and blocks until it's finished or interrupted.
      Throws:
      InterruptedException - if current thread is interrupted
    • stop

      public void stop()
      Stops watching for changes on file system.