org.apache.cocoon.framework
Class Monitor

java.lang.Object
  |
  +--org.apache.cocoon.framework.Monitor

public class Monitor
extends java.lang.Object

This class watches over the changes of indicated resources.

Version:
$Revision: 1.1 $ $Date: 1999/09/13 00:24:43 $
Author:
Stefano Mazzocchi

Inner Class Summary
(package private)  class Monitor.Container
           
 
Field Summary
private  java.util.Hashtable table
           
 
Constructor Summary
Monitor(int capacity)
           
 
Method Summary
 boolean hasChanged(java.lang.Object key)
          Queries the monitor for changes.
private  long timestamp(java.lang.Object resource)
          Create a timestamp indicating the last modified time of the given resource.
 void watch(java.lang.Object key, java.lang.Object resource)
          Tells the monitor to watch the given resource, timestamps it and associate it to the given key.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

table

private java.util.Hashtable table
Constructor Detail

Monitor

public Monitor(int capacity)
Method Detail

watch

public void watch(java.lang.Object key,
                  java.lang.Object resource)
Tells the monitor to watch the given resource, timestamps it and associate it to the given key.

hasChanged

public boolean hasChanged(java.lang.Object key)
Queries the monitor for changes. For maximum reliability, this method is synchronous, but less reliable for faster asynchronous versions could be implemented. Returns true if the resource associated to the given key has changed since the last call to watch. WARNING: due to a stupid bug in "FileURLConnection", the class that implements the "file:" protocol for the java.net.URL framework, the getLastModified() method always returns 0. For this reason, the use of the File resource is strongly suggested over the "file:" type URL. NOTE: this may not be (and should not be) the case in other virtual machine implementations or if we rewrite the URL handler ourselves (which I don't care to do at this point).

timestamp

private long timestamp(java.lang.Object resource)
Create a timestamp indicating the last modified time of the given resource.


Copyright 1999 Java Apache Project. All Rights Reserved.