|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectwt.jmx.core.FileWatcher
public abstract class FileWatcher
Provides ability to watch and load a file upon changes via a fairly general URL abstraction.
Note this class is not itself properly configured for direct persistence via Encoder;
rather it is suggested that controlling properties of interest be exposed in an aggregating MBean.
Supported API: true
Extendable: true
| Nested Class Summary | |
|---|---|
static class |
FileWatcher.Adapter
FileWatcher subclass with no-op overrides of all abstract methods. |
| Constructor Summary | |
|---|---|
FileWatcher()
Constructs instance of FileWatcher which uses itself as the object to sychronize against. |
|
FileWatcher(Object lockObject)
Constructs instance of FileWatcher which uses the specified object as the object to sychronize against. |
|
| Method Summary | |
|---|---|
int |
getFileCheckInterval()
Get time interval at which file is checked for updates (in seconds); a non-positive time-interval implies no file update checking Supported API: true |
BufferedInputStream |
getFileInputStream()
Get input stream for file Supported API: true |
protected OutputStream |
getFileOutputStream()
Get output stream for file Supported API: true |
String |
getFileRef()
Get URL, file path, or classpath-based resource reference string for file Supported API: true |
URL |
getFileURL()
Get URL to file Supported API: true |
String |
getFileURLString()
Get URL to file as String. |
Object |
getLockObject()
Returns object used by this instance for locking purposes; default to 'this' unless FileWatcher(Object) constructor is used. |
boolean |
isExistingFileOnly()
Whether only existing files are to be handled or whether reference may be to a file yet to be created. |
boolean |
isSavingCopy()
Returns true if and only if in process of saveACopyAs(). |
abstract void |
load()
Method to load from file; to be overriden by subclasses Supported API: true |
void |
reload()
Reload data from file Supported API: true |
void |
resetFileLastModified()
Reset this object's record of the file's last modification date. |
void |
save()
Save data to file Supported API: true |
abstract void |
save(OutputStream out)
Method to save data to the file; to be overriden by subclasses Supported API: true |
void |
saveACopyAs(String fileRef)
Save data to another file but do not change this object to reference the new file Supported API: true |
void |
saveAs(String fileRef)
Save data to another file and change this object to reference the new file Supported API: true |
void |
setExistingFileOnly(boolean existingFileOnly)
Set whether only existing files are to be handled or whether reference may be to a file yet to be created. |
void |
setFileCheckInterval(int fileCheckIntervalInSeconds)
Set time interval at which file is checked for updates (in seconds); a non-positive time-interval implies no file update checking Supported API: true |
void |
setFileRef(String fileRef)
Set URL, file path, or classpath-based resource reference string for file Supported API: true |
void |
setFileURL(URL fileURL)
Set URL to file Supported API: true |
void |
start()
Starts file update checker. |
void |
stop()
Stops file update checker. |
abstract void |
unload()
Method to unload/clear data loaded from file (as part of a reload); to be overriden by subclasses Supported API: true |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileWatcher()
public FileWatcher(Object lockObject)
lockObject - Object to synchronize against, if null, 'this' is used instead; see getLockObject()| Method Detail |
|---|
public abstract void load()
throws IOException
IOExceptionpublic abstract void unload()
public abstract void save(OutputStream out)
throws IOException,
URISyntaxException
IOException
URISyntaxExceptionpublic Object getLockObject()
public void resetFileLastModified()
public boolean isExistingFileOnly()
public void setExistingFileOnly(boolean existingFileOnly)
public String getFileURLString()
public String getFileRef()
public void setFileRef(String fileRef)
throws IOException
IOExceptionpublic URL getFileURL()
public void setFileURL(URL fileURL)
throws IOException
IOExceptionpublic int getFileCheckInterval()
public void setFileCheckInterval(int fileCheckIntervalInSeconds)
public void reload()
throws IOException
IOException
public BufferedInputStream getFileInputStream()
throws IOException
IOException
protected OutputStream getFileOutputStream()
throws IOException,
URISyntaxException
IOException
URISyntaxException
public final void save()
throws IOException,
URISyntaxException
IOException
URISyntaxException
public void saveAs(String fileRef)
throws IOException,
URISyntaxException
IOException
URISyntaxException
public void saveACopyAs(String fileRef)
throws IOException,
URISyntaxException
IOException
URISyntaxExceptionpublic boolean isSavingCopy()
public void start()
public void stop()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||