|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mmbase.util.ResourceWatcher
public abstract class 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' one 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<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. |
(package private) static String |
resourceBuilder
|
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. |
| Constructor Summary | |
|---|---|
protected |
ResourceWatcher()
Constructor, defaulting to the Root ResourceLoader (see ResourceLoader.getConfigurationRoot()). |
protected |
ResourceWatcher(ResourceLoader rl)
Constructor. |
protected |
ResourceWatcher(ResourceLoader rl,
boolean administrate)
|
| 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. |
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 |
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()
|
static void |
reinitWatchers()
|
void |
remove(String resourceName)
|
void |
setDelay(long delay)
Set the delay to observe between each check of the file changes. |
static void |
setResourceBuilder(String builder)
Sets the MMBase builder which must be used for resource. |
void |
start()
If a node (of the type 'resourceBuilder') changes, checks if it is a node belonging to one of the resource of this resource-watcher. |
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 |
|---|
static String resourceBuilder
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
| Constructor Detail |
|---|
protected ResourceWatcher(ResourceLoader rl)
protected ResourceWatcher(ResourceLoader rl,
boolean administrate)
protected ResourceWatcher()
ResourceLoader.getConfigurationRoot()).
| Method Detail |
|---|
public static void setResourceBuilder(String builder)
b - An String (this may be null if no such builder available)
RuntimeException - if builder was set already.public 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)
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 start()
onChange(java.lang.String) is called.
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()
toString in class Objectpublic static Set<ResourceWatcher> getResourceWatchers()
public long getDelay()
public Map<String,FileWatcher> getFileWatchers()
public boolean isRunning()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||