public class WatchDog<T,C extends WatchDog.Observer>
extends java.lang.Object
implements java.lang.Runnable
org.apache.log4j.helpers.FileWatchdog.
Modifications have been made to support additional abstract ressource and more events (creation, deletion and updates), and to allow "manual"
invocations of check() (i.e wihtout having to use a thread) while preserving time checking.
Now two use cases coexist:
| Modifier and Type | Class and Description |
|---|---|
static class |
WatchDog.DefaultObserver<A>
A default implementation of #ChangeHandler.
|
static class |
WatchDog.FileMutable |
static class |
WatchDog.FileSetMutable |
static interface |
WatchDog.Mutable<T>
have you said that duck typing would be nice?
|
static interface |
WatchDog.Observer<A> |
| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_DELAY |
protected WatchDog.Mutable<T> |
mutable |
protected C |
observer |
| Constructor and Description |
|---|
WatchDog() |
WatchDog(WatchDog.Mutable<T> mutable) |
WatchDog(WatchDog.Mutable<T> mutable,
C observer) |
WatchDog(WatchDog.Mutable<T> mutable,
long delay) |
| Modifier and Type | Method and Description |
|---|---|
void |
check() |
long |
getDelay() |
WatchDog.Mutable<T> |
getMutable() |
C |
getObserver() |
void |
run() |
void |
setDelay(long delay) |
static <C extends WatchDog.Observer> |
watchFile(java.io.File file,
C handler) |
static <C extends WatchDog.Observer> |
watchFiles(java.util.List<java.io.File> files,
C handler) |
public static final long DEFAULT_DELAY
protected WatchDog.Mutable<T> mutable
protected C extends WatchDog.Observer observer
public WatchDog()
public WatchDog(WatchDog.Mutable<T> mutable, long delay)
mutable - the object to watch closelydelay - between two checkspublic WatchDog(WatchDog.Mutable<T> mutable, C observer)
public WatchDog(WatchDog.Mutable<T> mutable)
public WatchDog.Mutable<T> getMutable()
public C getObserver()
public long getDelay()
public void setDelay(long delay)
public void run()
run in interface java.lang.Runnablepublic final void check()
public static <C extends WatchDog.Observer> WatchDog<java.lang.Long,C> watchFile(java.io.File file, C handler)
public static <C extends WatchDog.Observer> WatchDog<java.util.Map<java.io.File,java.lang.Long>,C> watchFiles(java.util.List<java.io.File> files, C handler)