public class DirectoryWatcher extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
DirectoryWatcher.FileChangedListener
An interface used to listen on file changed events.
|
Constructor and Description |
---|
DirectoryWatcher(Path root,
DirectoryWatcher.FileChangedListener listener,
CdsMojoLogger logger,
List<String> includes,
List<String> excludes)
Constructs a new
DirectoryWatcher instance. |
Modifier and Type | Method and Description |
---|---|
void |
join()
Joins the watch thread and blocks until it's finished or interrupted.
|
void |
start()
Starts asynchronously watching for changes on the file system.
|
void |
stop()
Stops watching for changes on file system.
|
public DirectoryWatcher(Path root, DirectoryWatcher.FileChangedListener listener, CdsMojoLogger logger, List<String> includes, List<String> excludes)
DirectoryWatcher
instance.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 excludeNullPointerException
- if any of the required arguments is null
public void start() throws IOException
IOException
- if registering for watching failedpublic void join() throws InterruptedException
InterruptedException
- if current thread is interruptedpublic void stop()
Copyright © 2023. All rights reserved.