public class WatchManager extends AbstractLifeCycle
FileWatcher
s.FileWatcher
,
ConfigurationScheduler
Modifier and Type | Class and Description |
---|---|
private class |
WatchManager.ConfigurationMonitor |
private class |
WatchManager.WatchRunnable |
LifeCycle.State
Modifier and Type | Field and Description |
---|---|
private java.util.List<WatchEventService> |
eventServiceList |
private java.util.concurrent.ScheduledFuture<?> |
future |
private java.util.UUID |
id |
private int |
intervalSeconds |
private static Logger |
logger |
private ConfigurationScheduler |
scheduler |
private java.util.concurrent.ConcurrentMap<Source,WatchManager.ConfigurationMonitor> |
watchers |
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
Constructor and Description |
---|
WatchManager(ConfigurationScheduler scheduler) |
Modifier and Type | Method and Description |
---|---|
void |
checkFiles() |
java.util.Map<Source,Watcher> |
getConfigurationWatchers()
Return the ConfigurationWaatchers.
|
private java.util.List<WatchEventService> |
getEventServices() |
java.util.UUID |
getId() |
int |
getIntervalSeconds()
Gets how often this manager checks for file modifications.
|
java.util.Map<java.io.File,FileWatcher> |
getWatchers()
Deprecated.
use getConfigurationWatchers.
|
boolean |
hasEventListeners() |
private java.lang.String |
millisToString(long millis) |
void |
reset()
Resets all file monitors to their current last modified time.
|
void |
reset(java.io.File file)
Resets the file monitor for the given file being watched to its current last modified time.
|
void |
reset(Source source)
Resets the configuration monitor for the given file being watched to its current last modified time.
|
void |
setIntervalSeconds(int intervalSeconds) |
void |
start() |
boolean |
stop(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current
thread is interrupted, whichever happens first.
|
java.lang.String |
toString() |
void |
unwatch(Source source)
Unwatches the given file.
|
void |
unwatchFile(java.io.File file)
Unwatches the given file.
|
void |
watch(Source source,
Watcher watcher)
Watches the given file.
|
void |
watchFile(java.io.File file,
FileWatcher fileWatcher)
Watches the given file.
|
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop
private static Logger logger
private final java.util.concurrent.ConcurrentMap<Source,WatchManager.ConfigurationMonitor> watchers
private int intervalSeconds
private java.util.concurrent.ScheduledFuture<?> future
private final ConfigurationScheduler scheduler
private final java.util.List<WatchEventService> eventServiceList
private final java.util.UUID id
public WatchManager(ConfigurationScheduler scheduler)
public java.util.UUID getId()
public boolean hasEventListeners()
public void reset()
This allows you to start, stop, reset and start again a manager, without triggering file modified events if the a watched file has changed during the period of time when the manager was stopped.
public void reset(java.io.File file)
This allows you to start, stop, reset and start again a manager, without triggering file modified events if the given watched file has changed during the period of time when the manager was stopped.
file
- the file for the monitor to reset.public void reset(Source source)
This allows you to start, stop, reset and start again a manager, without triggering file modified events if the given watched configuration has changed during the period of time when the manager was stopped.
source
- the Source for the monitor to reset.public void setIntervalSeconds(int intervalSeconds)
public int getIntervalSeconds()
public void start()
start
in interface LifeCycle
start
in class AbstractLifeCycle
public boolean stop(long timeout, java.util.concurrent.TimeUnit timeUnit)
LifeCycle2
stop
in interface LifeCycle2
stop
in class AbstractLifeCycle
timeout
- the maximum time to waittimeUnit
- the time unit of the timeout argumentpublic void unwatchFile(java.io.File file)
file
- the file to stop watching.public void unwatch(Source source)
source
- the Source to stop watching.
the file to stop watching.public void checkFiles()
public void watchFile(java.io.File file, FileWatcher fileWatcher)
file
- the file to watch.fileWatcher
- the watcher to notify of file changes.public void watch(Source source, Watcher watcher)
source
- the source to watch.watcher
- the watcher to notify of file changes.public java.util.Map<java.io.File,FileWatcher> getWatchers()
public java.util.Map<Source,Watcher> getConfigurationWatchers()
private java.lang.String millisToString(long millis)
private java.util.List<WatchEventService> getEventServices()
public java.lang.String toString()
toString
in class java.lang.Object