cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon Cocoon.java
Date Mon, 10 Dec 2001 05:46:47 GMT
giacomo     01/12/09 21:46:46

  Modified:    src/org/apache/cocoon Cocoon.java
  Log:
  Added Resource Monitor in Cocoon.java
  Submitted by:	Gerhard Froehlich <g-froehlich@gmx.de>
  
  Revision  Changes    Path
  1.34      +44 -4     xml-cocoon2/src/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- Cocoon.java	2001/12/06 18:54:03	1.33
  +++ Cocoon.java	2001/12/10 05:46:46	1.34
  @@ -59,6 +59,8 @@
   import org.apache.avalon.excalibur.component.ExcaliburComponentManager;
   import org.apache.avalon.excalibur.logger.LogKitManageable;
   import org.apache.avalon.excalibur.logger.LogKitManager;
  +import org.apache.avalon.excalibur.monitor.FileResource;
  +import org.apache.avalon.excalibur.monitor.Monitor;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.component.Component;
  @@ -90,6 +92,8 @@
   import org.apache.cocoon.util.ClassUtils;
   import org.xml.sax.InputSource;
   
  +import java.beans.PropertyChangeListener;
  +import java.beans.PropertyChangeEvent;
   import java.io.BufferedInputStream;
   import java.io.File;
   import java.io.IOException;
  @@ -104,7 +108,7 @@
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
(Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
    * @author <a href="mailto:leo.sutic@inspireinfrastructure.com">Leo Sutic</a>
  - * @version CVS $Revision: 1.33 $ $Date: 2001/12/06 18:54:03 $
  + * @version CVS $Revision: 1.34 $ $Date: 2001/12/10 05:46:46 $
    */
   public class Cocoon
           extends AbstractLoggable
  @@ -116,7 +120,8 @@
                      Processor,
                      Contextualizable,
                      Composable,
  -                   LogKitManageable{
  +                   LogKitManageable,
  +                   PropertyChangeListener {
       /** The application context */
       private Context context;
   
  @@ -153,6 +158,12 @@
       /** the Processor if it is ThreadSafe */
       private Processor threadSafeProcessor = null;
   
  +    /** Resource Monitor */
  +    private Monitor monitor;
  +
  +    /** Last modified date */
  +    private long lastModified;
  +
       /**
        * Creates a new <code>Cocoon</code> instance.
        *
  @@ -171,6 +182,7 @@
        */
       public void compose(ComponentManager manager) {
           this.parentComponentManager = manager;
  +       
       }
   
       /**
  @@ -187,9 +199,14 @@
               try {
                   this.configurationFile = new URLSource((URL)context.get(Constants.CONTEXT_CONFIG_URL),
                                                          this.componentManager);
  +                  
  +               
               } catch (IOException ioe) {
                   getLogger().error("Could not open configuration file.", ioe);
                   throw new ContextException("Could not open configuration file.", ioe);
  +            } catch (Exception e) {
  +                getLogger().error("contextualize(..) Exception", e);
  +                throw new ContextException("contextualize(..) Exception", e);
               }
           }
       }
  @@ -424,6 +441,18 @@
           }
           this.componentManager.configure(conf);
   
  +        /** Monitoring the Configuration source */
  +        try {
  +            this.monitor = (Monitor)this.componentManager.lookup(Monitor.ROLE);
  +            URL configURL = new URL(configurationFile.getSystemId());
  +            getLogger().debug("Configuration path=" + configURL.getFile());
  +            FileResource file = new FileResource(configURL.getFile());
  +            file.addPropertyChangeListener(this);
  +            monitor.addResource(file);
  +        } catch (Exception e) {
  +            getLogger().error("Caught Exception while setting up the Resource Monitor",
e);
  +        }
  +
           return conf;
       }
   
  @@ -434,8 +463,8 @@
        * @return a <code>boolean</code> value
        */
       public boolean modifiedSince(long date) {
  -        this.configurationFile.refresh();
  -        return date < this.configurationFile.getLastModified();
  +        getLogger().debug("modifiedSince(..) date=" + date);
  +        return date < this.getLastModified();
       }
   
       /**
  @@ -733,4 +762,15 @@
           --activeRequestCount;
       }
   
  +    public void propertyChange(PropertyChangeEvent evt) {
  +        setLastModified(((Long)evt.getNewValue()).longValue());
  +    }
  +
  +    private void setLastModified(long _lastModified) {
  +        lastModified = _lastModified;
  +    }
  +
  +    private long getLastModified() {
  +        return lastModified;
  +    }
   }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message