public class PathWatcher extends AbstractLifeCycle implements Runnable
Suitable replacement for the old Scanner implementation.
Allows for configured Excludes and Includes using FileSystem.getPathMatcher(String) syntax.
Reports activity via registered PathWatcher.Listeners
| Modifier and Type | Class and Description |
|---|---|
static class |
PathWatcher.Config |
static interface |
PathWatcher.Listener
Listener for path change events
|
static class |
PathWatcher.PathWatchEvent |
static class |
PathWatcher.PathWatchEventType |
AbstractLifeCycle.AbstractLifeCycleListener| Constructor and Description |
|---|
PathWatcher() |
| Modifier and Type | Method and Description |
|---|---|
void |
addDirectoryWatch(PathWatcher.Config baseDir)
Add a directory watch configuration to the the PathWatcher.
|
void |
addFileWatch(Path file) |
void |
addListener(PathWatcher.Listener listener) |
protected static <T> WatchEvent<T> |
cast(WatchEvent<?> event) |
protected void |
doStart() |
protected void |
doStop() |
Iterator<PathWatcher.Listener> |
getListeners() |
long |
getUpdateQuietTimeMillis() |
protected void |
notifyOnPathWatchEvent(PathWatcher.PathWatchEvent event) |
protected void |
register(Path dir,
PathWatcher.Config root) |
boolean |
removeListener(PathWatcher.Listener listener) |
void |
run() |
void |
setUpdateQuietTime(long duration,
TimeUnit unit) |
String |
toString() |
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stoppublic PathWatcher()
throws IOException
IOExceptionprotected static <T> WatchEvent<T> cast(WatchEvent<?> event)
public void addDirectoryWatch(PathWatcher.Config baseDir) throws IOException
baseDir - the base directory configuration to watchIOException - if unable to setup the directory watchpublic void addFileWatch(Path file) throws IOException
IOExceptionpublic void addListener(PathWatcher.Listener listener)
protected void doStart()
throws Exception
doStart in class AbstractLifeCycleExceptionprotected void doStop()
throws Exception
doStop in class AbstractLifeCycleExceptionpublic Iterator<PathWatcher.Listener> getListeners()
public long getUpdateQuietTimeMillis()
protected void notifyOnPathWatchEvent(PathWatcher.PathWatchEvent event)
protected void register(Path dir, PathWatcher.Config root) throws IOException
IOExceptionpublic boolean removeListener(PathWatcher.Listener listener)
public void setUpdateQuietTime(long duration,
TimeUnit unit)
Copyright © 1995-2015 Webtide. All Rights Reserved.