
public abstract class AbstractFileSystemWatcher extends AbstractService
Thread.State, Thread.UncaughtExceptionHandler| Modifier and Type | Field and Description |
|---|---|
private Path |
path |
private WatchService |
watcher |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
AbstractFileSystemWatcher(String dir)
Builds a file system watcher for a single directory.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
created(Path filename)
This method is invoked whenever a new file is created.
|
protected abstract void |
deleted(Path filename)
This method is invoked whenever a file is deleted.
|
Path |
getPath() |
protected abstract void |
modified(Path filename)
This method is invoked whenever a file is modified.
|
abstract void |
overflow()
This method is invoked whenever an overflow event occurs (see
java.nio.file.StandardWatchEventKinds.OVERFLOW).
|
void |
run() |
void |
stopService()
If called, the service must stop.
|
protected abstract void |
unknown(WatchEvent<Path> event)
Something nasty happened, and the system received an unexpected event.
|
isServiceAlive, setAliveactiveCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldprivate final Path path
private final WatchService watcher
public AbstractFileSystemWatcher(String dir) throws IOException
dir - the directory to register toIOException - in case of I/O errorsprotected abstract void created(Path filename)
filename - the file which has been createdprotected abstract void deleted(Path filename)
filename - the file which has been deletedpublic Path getPath()
protected abstract void modified(Path filename)
filename - the file which has been modifiedpublic abstract void overflow()
public void stopService()
AbstractServicestopService in class AbstractServiceprotected abstract void unknown(WatchEvent<Path> event)
event - the bad event