|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
org.zkoss.io.FileWatchdog
public class FileWatchdog
File modification monitor thread. It monitors a gving file in a lowest priority thread. Then, if it detects any modification, invokes a giving interface. Note: Callback.onModified is at least called once.
Caller has to implement the FileWatchdog.Callback interface. Then,
new FileWatchdog(filename, 30000, callback).start();
This class is extended from Thread, so you could manipulate it as a normal thread, such as interrupt, suspend, and change priority.
The watchdog executes at the lowest priority, so it won't affect much of the system performance.
| Nested Class Summary | |
|---|---|
static interface |
FileWatchdog.Callback
The interface to implement when using a FileWatchdog. |
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary |
|---|
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
FileWatchdog(java.io.File file,
long delay,
FileWatchdog.Callback callback)
Constructor. |
|
FileWatchdog(java.lang.String filename,
long delay,
FileWatchdog.Callback callback)
Constructor. |
|
| Method Summary | |
|---|---|
void |
cease()
Stops the thread. |
void |
run()
|
void |
start()
|
| Methods inherited from class java.lang.Thread |
|---|
activeCount, 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, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public FileWatchdog(java.io.File file,
long delay,
FileWatchdog.Callback callback)
file - the filedelay - the delay in milliseconds to wait between each checkcallback - the callback
public FileWatchdog(java.lang.String filename,
long delay,
FileWatchdog.Callback callback)
filename - the filenamedelay - the delay in milliseconds to wait between each checkcallback - the callback| Method Detail |
|---|
public void start()
start in class java.lang.Threadpublic void cease()
public void run()
run in interface java.lang.Runnablerun in class java.lang.Thread
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||