cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/framework Monitor.java
Date Wed, 23 Feb 2000 00:49:59 GMT
stefano     00/02/22 16:49:59

  Modified:    src/org/apache/cocoon/framework Monitor.java
  Log:
  improved monitor
  
  Revision  Changes    Path
  1.5       +29 -22    xml-cocoon/src/org/apache/cocoon/framework/Monitor.java
  
  Index: Monitor.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/framework/Monitor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Monitor.java	2000/02/13 18:29:22	1.4
  +++ Monitor.java	2000/02/23 00:49:58	1.5
  @@ -1,36 +1,36 @@
  -/*-- $Id: Monitor.java,v 1.4 2000/02/13 18:29:22 stefano Exp $ -- 
  +/*-- $Id: Monitor.java,v 1.5 2000/02/23 00:49:58 stefano Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
    ============================================================================
  - 
  +
    Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
  - 
  +
    Redistribution and use in source and binary forms, with or without modifica-
    tion, are permitted provided that the following conditions are met:
  - 
  +
    1. Redistributions of  source code must  retain the above copyright  notice,
       this list of conditions and the following disclaimer.
  - 
  +
    2. Redistributions in binary form must reproduce the above copyright notice,
       this list of conditions and the following disclaimer in the documentation
       and/or other materials provided with the distribution.
  - 
  +
    3. The end-user documentation included with the redistribution, if any, must
       include  the following  acknowledgment:  "This product includes  software
       developed  by the  Apache Software Foundation  (http://www.apache.org/)."
       Alternately, this  acknowledgment may  appear in the software itself,  if
       and wherever such third-party acknowledgments normally appear.
  - 
  +
    4. The names "Cocoon" and  "Apache Software Foundation"  must not be used to
       endorse  or promote  products derived  from this  software without  prior
       written permission. For written permission, please contact
       apache@apache.org.
  - 
  +
    5. Products  derived from this software may not  be called "Apache", nor may
       "Apache" appear  in their name,  without prior written permission  of the
       Apache Software Foundation.
  - 
  +
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
    FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  @@ -41,12 +41,12 @@
    ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
    (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
    THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  - 
  +
    This software  consists of voluntary contributions made  by many individuals
    on  behalf of the Apache Software  Foundation and was  originally created by
  - Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache 
  + Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
    Software Foundation, please see <http://www.apache.org/>.
  - 
  +
    */
   package org.apache.cocoon.framework;
   
  @@ -58,27 +58,27 @@
    * This class watches over the changes of indicated resources.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.4 $ $Date: 2000/02/13 18:29:22 $
  + * @version $Revision: 1.5 $ $Date: 2000/02/23 00:49:58 $
    */
   
   public class Monitor {
  -    
  +
       private Hashtable table;
  -    
  +
       class Container {
           public Object resource;
           public long timestamp;
  -        
  +
           public Container(Object resource, long timestamp) {
               this.resource = resource;
               this.timestamp = timestamp;
           }
       }
  -    
  +
       public Monitor(int capacity) {
           this.table = new Hashtable(capacity);
       }
  -    
  +
       /**
        * Tells the monitor to watch the given resource, timestamps it
        * and associate it to the given key.
  @@ -86,7 +86,7 @@
       public void watch(Object key, Object resource) {
           this.table.put(key, new Container(resource, timestamp(resource)));
       }
  -    
  +
       /**
        * Queries the monitor for changes. For maximum reliability, this
        * method is synchronous, but less reliable for faster asynchronous
  @@ -103,8 +103,8 @@
        * virtual machine implementations or if we rewrite the URL
        * handler ourselves (which I don't care to do at this point).
        */
  -    public boolean hasChanged(Object key) {
  -        Object o = this.table.get(key);
  +    public boolean hasChanged(Object context) {
  +        Object o = this.table.get(context);
           if (o != null) {
               Container c = (Container) o;
               return c.timestamp != timestamp(c.resource);
  @@ -112,7 +112,14 @@
               return true;
           }
       }
  -    
  +
  +    /**
  +     * Invalidates the given context.
  +     */
  +    public void invalidate(Object context) {
  +        if (context != null) this.table.remove(context);
  +    }
  +
       /**
        * Create a timestamp indicating the last modified time
        * of the given resource.
  
  
  

Mime
View raw message