|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mmbase.util.ResourceWatcher
Like FileWatcher but for Resources. If (one of the) file(s) to which the resource resolves
to is added or changed, it's onChange will be triggered, if not a 'more important' wil was
existing already. If a file is removed, and was the most important one, it will be removed from the filewatcher.
FileWatcher,
ResourceLoader| Nested Class Summary | |
protected class |
ResourceWatcher.ResourceFileWatcher
A FileWatcher associated with a certain resource of this ResourceWatcher. |
| Field Summary | |
protected Map |
fileWatchers
Wrapped FileWatcher for watching the file-resources. |
protected Map |
nodeNumberToResourceName
When a resource is loaded from a Node, we must know which Nodes correspond to which resource. |
protected ResourceLoader |
resourceLoader
The resource-loader associated with this ResourceWatcher. |
protected SortedSet |
resources
All resources watched by this ResourceWatcher. |
| Constructor Summary | |
protected |
ResourceWatcher()
Constructor, defaulting to the Root ResourceLoader (see ResourceLoader.getConfigurationRoot()). |
protected |
ResourceWatcher(ResourceLoader rl)
Constructor. |
| Method Summary | |
void |
add(String resourceName)
|
void |
add(URL url)
If you resolved a resource already to an URL, you can still add it for watching. |
void |
clear()
Removes all resources. |
protected void |
createFileWatcher(String resource)
When a resource is added to this ResourceWatcher, this method is called to create a ResourceWatcher.ResourceFileWatcher, and add all files associated with the resource to it. |
void |
exit()
Stops watching. |
ResourceLoader |
getResourceLoader()
The associated ResourceLoader |
Set |
getResources()
|
protected boolean |
mapNodeNumber(String resource)
When a resource is added to this ResourceWatcher, this method is called to check wether a ResourceBuilder node is associated with this resource. |
void |
notify(NodeEvent event)
If a node (of the type 'resourceBuilder') changes, checks if it is a node belonging to one of the resource of this resource-watcher. |
void |
onChange()
Calls onChange(String) for every added resource. |
abstract void |
onChange(String resourceName)
Put here the stuff that has to be executed, when a file has been changed. |
void |
remove(String resourceName)
|
void |
setDelay(long delay)
Set the delay to observe between each check of the file changes. |
void |
start()
|
String |
toString()
Shows the 'contents' of the filewatcher. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected SortedSet resources
protected Map nodeNumberToResourceName
notify(NodeEvent)
protected Map fileWatchers
protected ResourceLoader resourceLoader
| Constructor Detail |
protected ResourceWatcher(ResourceLoader rl)
protected ResourceWatcher()
ResourceLoader.getConfigurationRoot()).
| Method Detail |
public Set getResources()
public ResourceLoader getResourceLoader()
public void add(String resourceName)
resourceName - The resource to be monitored.public void add(URL url)
protected void createFileWatcher(String resource)
ResourceWatcher.ResourceFileWatcher, and add all files associated with the resource to it.
protected boolean mapNodeNumber(String resource)
notify(NodeEvent) in case of a
node-deletion.
public void notify(NodeEvent event)
onChange(java.lang.String) is called.
notify in interface NodeEventListenerpublic void start()
public abstract void onChange(String resourceName)
resourceName - The resource that was changed.public final void onChange()
onChange(String) for every added resource.
public void setDelay(long delay)
public void remove(String resourceName)
public void clear()
public void exit()
public String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||