public abstract class ResourceWatcher extends Object implements NodeEventListener
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' one was
existing already. If a file is removed, and was the most important one, it will be removed from the filewatcher.FileWatcher,
ResourceLoader| Modifier and Type | Class and Description |
|---|---|
protected class |
ResourceWatcher.ResourceFileWatcher
A FileWatcher associated with a certain resource of this ResourceWatcher.
|
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,FileWatcher> |
fileWatchers
Wrapped FileWatcher for watching the file-resources.
|
protected Map<Integer,String> |
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<String> |
resources
All resources watched by this ResourceWatcher.
|
(package private) static Map<ResourceWatcher,Object> |
resourceWatchers
All instantiated ResourceWatchers.
|
| Modifier | Constructor and Description |
|---|---|
protected |
ResourceWatcher()
Constructor, defaulting to the Root ResourceLoader (see
ResourceLoader.getConfigurationRoot()). |
protected |
ResourceWatcher(ResourceLoader rl)
Constructor.
|
protected |
ResourceWatcher(ResourceLoader rl,
boolean administrate) |
| Modifier and Type | Method and Description |
|---|---|
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
FileWatcher, and add all files associated with the resource to it. |
void |
exit()
Stops watching.
|
long |
getDelay() |
Map<String,FileWatcher> |
getFileWatchers() |
ResourceLoader |
getResourceLoader()
The associated ResourceLoader
|
Set<String> |
getResources() |
static Set<ResourceWatcher> |
getResourceWatchers() |
boolean |
isRunning() |
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.
|
protected void |
readdResources() |
(package private) static void |
reinitWatchers() |
void |
remove(String resourceName) |
void |
setDelay(long delay)
Set the delay to observe between each check of the file changes.
|
(package private) static void |
setResourceBuilder()
Considers all resource-watchers.
|
void |
start() |
String |
toString()
Shows the 'contents' of the filewatcher.
|
static final Map<ResourceWatcher,Object> resourceWatchers
protected final SortedSet<String> resources
protected final Map<Integer,String> nodeNumberToResourceName
notify(NodeEvent)protected final Map<String,FileWatcher> fileWatchers
protected final ResourceLoader resourceLoader
protected ResourceWatcher(ResourceLoader rl)
protected ResourceWatcher(ResourceLoader rl, boolean administrate)
protected ResourceWatcher()
ResourceLoader.getConfigurationRoot()).static void setResourceBuilder()
static void reinitWatchers()
public Set<String> 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)
FileWatcher, 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)
delay - The delay in millisecondspublic void remove(String resourceName)
public void clear()
protected void readdResources()
public void exit()
public String toString()
public static Set<ResourceWatcher> getResourceWatchers()
public long getDelay()
public Map<String,FileWatcher> getFileWatchers()
public boolean isRunning()
MMBase 1.9-SNAPSHOT - ${javadoctimestamp}