ahc.io
Class FileWatcher

java.lang.Object
  |
  +--ahc.io.FileWatcher

public abstract class FileWatcher
extends java.lang.Object

The purpose of this class is to act as a cache between a read-only file (e.g. a configuration file) and its read object representation.
Clients access the object representation of the object through the getData method. That checks the timestamp of the underlying file to determine if it has changed since it was last read. In the common case that it has not changed, a cached copy of the object representing the file is returned, and only when necessary the read method provided by the subclass is called to actually access the file.
The minReadInterval parameter serves as a "security buffer" in case the file is changed incrementally so that the file's time stamp is changed before the changes are complete and the file is again consistent. The file is reread only when this interval has passed since the last change to the timestamp of the file.

Author:
Arno Haase

Constructor Summary
FileWatcher(java.lang.String filename)
           
FileWatcher(java.lang.String filename, long minRereadInterval)
           
 
Method Summary
 java.lang.Object getData()
           
protected abstract  java.lang.Object read(java.io.InputStream is)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileWatcher

public FileWatcher(java.lang.String filename)

FileWatcher

public FileWatcher(java.lang.String filename,
                   long minRereadInterval)
Method Detail

getData

public java.lang.Object getData()
                         throws java.io.IOException
java.io.IOException

read

protected abstract java.lang.Object read(java.io.InputStream is)
                                  throws java.io.IOException
java.io.IOException