Package com.sap.cds.maven.plugin.util
Class DirectoryWatcher
java.lang.Object
com.sap.cds.maven.plugin.util.DirectoryWatcher
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
An interface used to listen on file changed events. -
Constructor Summary
ConstructorDescriptionDirectoryWatcher
(Path root, DirectoryWatcher.FileChangedListener listener, CdsMojoLogger logger, List<String> includes, List<String> excludes) Constructs a newDirectoryWatcher
instance. -
Method Summary
-
Constructor Details
-
DirectoryWatcher
public DirectoryWatcher(Path root, DirectoryWatcher.FileChangedListener listener, CdsMojoLogger logger, List<String> includes, List<String> excludes) Constructs a newDirectoryWatcher
instance.- Parameters:
root
- the root of the directory sub-tree to watchlistener
- the event listenerlogger
- the mandatory loggerincludes
- an optional list with GLOB patterns describing the files to be includeexcludes
- an optional list with GLOB patterns describing the files to be exclude- Throws:
NullPointerException
- if any of the required arguments isnull
-
-
Method Details
-
start
Starts asynchronously watching for changes on the file system.- Throws:
IOException
- if registering for watching failed
-
join
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.
-