org.apache.ode.utils
Class WatchDog<T,C extends WatchDog.Observer>
java.lang.Object
org.apache.ode.utils.WatchDog<T,C>
- All Implemented Interfaces:
- java.lang.Runnable
public class WatchDog<T,C extends WatchDog.Observer>
- extends java.lang.Object
- implements java.lang.Runnable
This class is based on 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:
- Pass an instance of
WatchDog
to a new thread (WatchDog
is a Runnable
).
So that check ()
will be called automatically every delay
milliseconds.
- Invoke
check ()
only when you feel like it. If the expiration date previously set is lower than NOW then event
callback methods will be invoked accordingly.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_DELAY
public static final long DEFAULT_DELAY
- See Also:
- Constant Field Values
mutable
protected WatchDog.Mutable<T> mutable
observer
protected C extends WatchDog.Observer observer
WatchDog
public WatchDog()
WatchDog
public WatchDog(WatchDog.Mutable<T> mutable,
long delay)
- Parameters:
mutable
- the object to watch closelydelay
- between two checks
WatchDog
public WatchDog(WatchDog.Mutable<T> mutable,
C observer)
WatchDog
public WatchDog(WatchDog.Mutable<T> mutable)
- See Also:
WatchDog(org.apache.ode.utils.WatchDog.Mutable, long)
getMutable
public WatchDog.Mutable<T> getMutable()
getObserver
public C getObserver()
getDelay
public long getDelay()
setDelay
public void setDelay(long delay)
run
public void run()
- Specified by:
run
in interface java.lang.Runnable
check
public final void check()
watchFile
public static <C extends WatchDog.Observer> WatchDog<java.lang.Long,C> watchFile(java.io.File file,
C handler)
watchFiles
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)