net.sf.jour.util
Class FileWatchdog

java.lang.Object
  extended byjava.lang.Thread
      extended bynet.sf.jour.util.FileWatchdog
All Implemented Interfaces:
java.lang.Runnable

public class FileWatchdog
extends java.lang.Thread

Check every now and then that a certain file has not changed. If it has, then call the doOnChange()method. This is build base on org.apache.log4j.helpers.FileWatchdog

Since:
version 0.9.1
Author:
Ceki Gülcü

Field Summary
static long DEFAULT_DELAY
          The default delay between every file modification check, set to 60 seconds.
protected  long delay
          The delay to observe between every check.
(package private)  java.io.File file
           
(package private)  long fileLength
           
protected  java.lang.String filename
          The name of the file to observe for changes.
(package private)  boolean interrupted
           
(package private)  long lastModif
           
(package private)  java.util.List listenerList
           
protected static org.apache.log4j.Logger log
           
(package private)  boolean warnedAlready
           
(package private) static java.util.Hashtable watchdogs
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected FileWatchdog(java.lang.String filename)
           
 
Method Summary
 void addListener(FileChageListener fileChageListener)
           
protected  void checkAndConfigure(boolean callOnChange)
           
 void doOnChange()
           
protected  boolean fileDetected()
           
 void finish()
           
static FileWatchdog getFileWatchdog(java.lang.String filename, boolean create)
           
 void run()
           
 void setDelay(long delay)
          Set the delay to observe between each check of the file changes.
 
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
 

Field Detail

log

protected static final org.apache.log4j.Logger log

DEFAULT_DELAY

public static final long DEFAULT_DELAY
The default delay between every file modification check, set to 60 seconds.

See Also:
Constant Field Values

filename

protected java.lang.String filename
The name of the file to observe for changes.


delay

protected long delay
The delay to observe between every check. By default set .


file

java.io.File file

lastModif

long lastModif

fileLength

long fileLength

warnedAlready

boolean warnedAlready

interrupted

boolean interrupted

listenerList

java.util.List listenerList

watchdogs

static java.util.Hashtable watchdogs
Constructor Detail

FileWatchdog

protected FileWatchdog(java.lang.String filename)
Method Detail

getFileWatchdog

public static FileWatchdog getFileWatchdog(java.lang.String filename,
                                           boolean create)

setDelay

public void setDelay(long delay)
Set the delay to observe between each check of the file changes.


addListener

public void addListener(FileChageListener fileChageListener)

doOnChange

public void doOnChange()

fileDetected

protected boolean fileDetected()

checkAndConfigure

protected void checkAndConfigure(boolean callOnChange)

finish

public void finish()

run

public void run()


Copyright © 2004 sourceforge. All Rights Reserved.