|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.lang.Thread
org.xins.common.io.FileWatcher
org.xins.common.io.HTTPFileWatcher
File watcher thread. This thread checks if a URL or a set of URLs changed and if it has, it notifies the listener. The check is performed every n seconds, where n can be configured.
Initially this thread will be a daemon thread. This can be changed by
calling Thread.setDaemon(boolean).
| Nested Class Summary |
| Nested classes inherited from class org.xins.common.io.FileWatcher |
FileWatcher.Listener |
| Field Summary |
| Fields inherited from class org.xins.common.io.FileWatcher |
_filePaths, _lastModified |
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
HTTPFileWatcher(String[] urls,
int interval,
FileWatcher.Listener listener)
Creates a new HTTPFileWatcher for the specified set of URLs,
with the specified interval. |
|
HTTPFileWatcher(String url,
FileWatcher.Listener listener)
Creates a new HTTPFileWatcher for the specified URL. |
|
HTTPFileWatcher(String url,
int interval,
FileWatcher.Listener listener)
Creates a new HTTPFileWatcher for the specified URL, with the
specified interval. |
|
| Method Summary | |
protected void |
firstCheck()
Performs the first check on the file to determine the date the file was last modified. |
protected long |
getLastModified()
Gets the time at which the last file was modified. |
protected void |
storeFiles(String[] files)
Stores the files in a class variable. |
| Methods inherited from class org.xins.common.io.FileWatcher |
check, end, getInterval, run, setInterval |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public HTTPFileWatcher(String url,
FileWatcher.Listener listener)
throws IllegalArgumentException
HTTPFileWatcher for the specified URL.
The interval must be set before the thread can be started.
url - the name of the URL to watch, cannot be null.listener - the object to notify on events, cannot be null.
IllegalArgumentException - if url == null || listener == null
public HTTPFileWatcher(String url,
int interval,
FileWatcher.Listener listener)
throws IllegalArgumentException
HTTPFileWatcher for the specified URL, with the
specified interval.
url - the name of the URL to watch, cannot be null.interval - the interval in seconds, must be greater than or equal to 0.
if the interval is 0 the interval must be set before the thread can
be started.listener - the object to notify on events, cannot be null.
IllegalArgumentException - if url == null || listener == null || interval < 0
public HTTPFileWatcher(String[] urls,
int interval,
FileWatcher.Listener listener)
throws IllegalArgumentException
HTTPFileWatcher for the specified set of URLs,
with the specified interval.
urls - the name of the URLs to watch, cannot be null.
It should also have at least one URL and none of the URLs should be null.interval - the interval in seconds, must be greater than or equal to 0.
if the interval is 0 the interval must be set before the thread can
be started.listener - the object to notify on events, cannot be null.
IllegalArgumentException - if urls == null || listener == null || interval < 0 || urls.length < 1
or if one of the URL is null.| Method Detail |
protected void storeFiles(String[] files)
FileWatcher
storeFiles in class FileWatcherfiles - the String files to check, cannot be null.protected void firstCheck()
FileWatcherSecurityException, then this
exception is logged and ignored.
firstCheck in class FileWatcher
protected long getLastModified()
throws SecurityException
FileWatcher
getLastModified in class FileWatcherSecurityException - if one of the file could not be read because of a security issue.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||