|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.sape.carbon.core.config.node.file.ConfigurationFileMonitor
This class manages a thread that monitors files for changes at a periodic interval. When a file is changed or removed, it is detected and the corresponding configuration node is refreshed.
Copyright 2003 Sapient
| Nested Class Summary | |
private class |
ConfigurationFileMonitor.Monitor
Runnable class that implements the monitor thread's functionality. |
private static class |
ConfigurationFileMonitor.NodeInfo
Helper class that maintains info about a node and its file. |
| Field Summary | |
private org.apache.commons.logging.Log |
log
|
private Map |
monitoredFiles
synchronized map of files that are being monitored key = (String) node absolute name value = NodeInfo object |
private Thread |
monitorThread
Thread monitoring files |
private long |
pollInterval
The interval at which the files are polled to see if they have changed |
private String |
threadName
Name of the trhead |
| Constructor Summary | |
ConfigurationFileMonitor(Node entryPoint,
long pollInterval)
Constructs a new ConfigurationFileMonitor |
|
| Method Summary | |
private void |
addFileToMonitor(Node fileNode)
Helper method to add a file to the monitor |
void |
childAdded(Node parent,
Node child)
updates the last modifed timestamp associate with parent and adds child to the monitored files map |
void |
childLoaded(Node parent,
Node child)
adds child to the monitored files map |
void |
interrupt()
Interrupts the monitor thread. |
private void |
monitorThreadEnded()
|
void |
nodeModified(Node node)
Updates the last modifed timestamp associated with the node |
void |
nodeRemoved(String removedNodeName)
removes the node from the monitored files map |
void |
start()
Starts the monitor thread. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private org.apache.commons.logging.Log log
private Map monitoredFiles
private Thread monitorThread
private String threadName
private long pollInterval
| Constructor Detail |
public ConfigurationFileMonitor(Node entryPoint,
long pollInterval)
entryPoint - the node that is the root of configuration hierachy
that is to be monitored. This does not need to be the root of the
entire configuration hierachy.pollInterval - the interval at which the files are polled to see if
they have changed| Method Detail |
public void nodeModified(Node node)
nodeModified in interface ConfigurationEventListenernode - the node that has been modified
public void childAdded(Node parent,
Node child)
childAdded in interface ConfigurationEventListenerparent - the node the child was added tochild - the child that was added
public void childLoaded(Node parent,
Node child)
childLoaded in interface ConfigurationEventListenerparent - the node that loaded the childchild - the child that was loadedpublic void nodeRemoved(String removedNodeName)
nodeRemoved in interface ConfigurationEventListenerremovedNodeName - the absolute name of the removed nodepublic void interrupt()
public void start()
private void monitorThreadEnded()
private void addFileToMonitor(Node fileNode)
fileNode -
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||