public final class PathWatcher extends AbstractApplicationObject<ApplicationContext> implements PathRegistrationEvent.Source, PathChangeEvent.Source, Resettable
WatchService
on registered Path
s. It has
event-notification support for two change-informations.
PathRegistrationEvent
is fired whenever a path was registered or
deregistered on the watch-servicePathChangeEvent
is fired whenever the watch-service has detected a
file-system change in any of the watched paths.Constructor and Description |
---|
PathWatcher(ApplicationContext ctx) |
Modifier and Type | Method and Description |
---|---|
void |
addPathChangeListener(PathChangeEvent.Listener l) |
void |
addPathRegistrationListener(PathRegistrationEvent.Listener l) |
void |
deregisterPath(java.nio.file.Path path)
Deregister everything starting with this path.
|
protected void |
fastRegisterPath(java.nio.file.Path path) |
BranchPathFilter |
getPathFilter() |
java.util.Map<java.nio.file.Path,java.nio.file.WatchKey> |
getWatchedPaths() |
boolean |
isPathWatched(java.nio.file.Path path) |
boolean |
isRunning() |
void |
registerPath(java.nio.file.Path path) |
void |
removePathChangeListener(PathChangeEvent.Listener l) |
void |
removePathRegistrationListener(PathRegistrationEvent.Listener l) |
void |
reset()
This method is called by the ResetButton on it's registered target.
|
void |
setCustomFilter(PathFilter filter)
Sets a filter which allows paths to be excluded from watching.
|
void |
setPermissionFilter(PathFilter filter) |
void |
startWatchService()
Creates and starts a new watch-service as an inner task.
|
void |
stopWatchService()
Stops the watch-service task.
|
getApplicationContext, getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel
configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString, toString
public PathWatcher(ApplicationContext ctx)
public void addPathRegistrationListener(PathRegistrationEvent.Listener l)
addPathRegistrationListener
in interface PathRegistrationEvent.Source
public void removePathRegistrationListener(PathRegistrationEvent.Listener l)
removePathRegistrationListener
in interface PathRegistrationEvent.Source
public void addPathChangeListener(PathChangeEvent.Listener l)
addPathChangeListener
in interface PathChangeEvent.Source
public void removePathChangeListener(PathChangeEvent.Listener l)
removePathChangeListener
in interface PathChangeEvent.Source
public void reset()
Resettable
reset
in interface Resettable
public void startWatchService()
public boolean isRunning()
public void stopWatchService()
public void registerPath(java.nio.file.Path path)
public java.util.Map<java.nio.file.Path,java.nio.file.WatchKey> getWatchedPaths()
protected void fastRegisterPath(java.nio.file.Path path) throws java.io.IOException
java.io.IOException
public void deregisterPath(java.nio.file.Path path)
public boolean isPathWatched(java.nio.file.Path path)
public final void setCustomFilter(PathFilter filter)
public final void setPermissionFilter(PathFilter filter)
public final BranchPathFilter getPathFilter()
Copyright © 2014 EsprIT-Systems. All Rights Reserved.