| java.lang.Object org.mmbase.util.ResourceWatcher
ResourceWatcher | abstract public class ResourceWatcher implements NodeEventListener(Code) | | Like
org.mmbase.util.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.
author: Michiel Meeuwissen since: MMBase-1.8 version: $Id: ResourceWatcher.java,v 1.19 2007/06/29 10:29:09 michiel Exp $ See Also: org.mmbase.util.FileWatcher See Also: org.mmbase.util.ResourceLoader |
Inner Class :protected class ResourceFileWatcher extends FileWatcher | |
Method Summary | |
public synchronized void | add(String resourceName) | public synchronized void | add(URL url) If you resolved a resource already to an URL, you can still add it for watching. | public synchronized void | clear() Removes all resources. | protected synchronized void | createFileWatcher(String resource) When a resource is added to this ResourceWatcher, this method is called to create a
FileWatcher , and add all files associated with the resource to it. | public synchronized void | exit() Stops watching. | public ResourceLoader | getResourceLoader() | public Set<String> | getResources() | protected synchronized 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. | public 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. | abstract public void | onChange(String resourceName) Put here the stuff that has to be executed, when a file has been changed. | final public void | onChange() Calls
ResourceWatcher.onChange(String) for every added resource. | public synchronized void | remove(String resourceName) | public synchronized void | setDelay(long delay) Set the delay to observe between each check of the file changes. | static void | setResourceBuilder() Considers all resource-watchers. | public synchronized void | start() | public String | toString() Shows the 'contents' of the filewatcher. |
fileWatchers | protected Map<String, FileWatcher> fileWatchers(Code) | | Wrapped FileWatcher for watching the file-resources. ResourceName -> FileWatcher.
|
nodeNumberToResourceName | protected Map<Integer, String> nodeNumberToResourceName(Code) | | When a resource is loaded from a Node, we must know which Nodes correspond to which
resource. You could ask the node itself, but if the node happens to be deleted, then you
can't know that any more. Used in
ResourceWatcher.notify(NodeEvent) |
resourceLoader | protected ResourceLoader resourceLoader(Code) | | The resource-loader associated with this ResourceWatcher.
|
resourceWatchers | static Set<ResourceWatcher> resourceWatchers(Code) | | All instantiated ResourceWatchers. Only used until setResourceBuilder is called. Then it
is set to null, and not used any more (also used in ResourceLoader).
|
resources | protected SortedSet<String> resources(Code) | | All resources watched by this ResourceWatcher. A Set of Strings. Often, a ResourceWatcher would watch only one resource.
|
add | public synchronized void add(String resourceName)(Code) | | Parameters: resourceName - The resource to be monitored. |
add | public synchronized void add(URL url)(Code) | | If you resolved a resource already to an URL, you can still add it for watching.
|
clear | public synchronized void clear()(Code) | | Removes all resources.
|
createFileWatcher | protected synchronized void createFileWatcher(String resource)(Code) | | When a resource is added to this ResourceWatcher, this method is called to create a
FileWatcher , and add all files associated with the resource to it.
|
exit | public synchronized void exit()(Code) | | Stops watching. Stops all filewatchers, removes observers.
|
getResources | public Set<String> getResources()(Code) | | Unmodifiable set of String of watched resources |
mapNodeNumber | protected synchronized boolean mapNodeNumber(String resource)(Code) | | When a resource is added to this ResourceWatcher, this method is called to check wether a
ResourceBuilder node is associated with this resource. If so, this methods maps the number of
the node to the resource name. This is needed in
ResourceWatcher.notify(NodeEvent) in case of a
node-deletion.
Whether a Node as found to map. |
notify | public void notify(NodeEvent event)(Code) | | If a node (of the type 'resourceBuilder') changes, checks if it is a node belonging to one of the resource of this resource-watcher.
If so,
ResourceWatcher.onChange is called.
|
onChange | abstract public void onChange(String resourceName)(Code) | | Put here the stuff that has to be executed, when a file has been changed.
Parameters: resourceName - The resource that was changed. |
remove | public synchronized void remove(String resourceName)(Code) | | |
setDelay | public synchronized void setDelay(long delay)(Code) | | Set the delay to observe between each check of the file changes.
Parameters: delay - The delay in milliseconds |
setResourceBuilder | static void setResourceBuilder()(Code) | | Considers all resource-watchers. Perhaps onChange must be called, because there is a node for this resource available now.
|
start | public synchronized void start()(Code) | | |
toString | public String toString()(Code) | | Shows the 'contents' of the filewatcher. It shows a list of files/last modified timestamps.
|
|
|