Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 84183 invoked by uid 500); 10 Dec 2001 06:06:37 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 84174 invoked by uid 500); 10 Dec 2001 06:06:37 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Date: 10 Dec 2001 05:46:47 -0000 Message-ID: <20011210054647.43328.qmail@icarus.apache.org> From: giacomo@apache.org To: xml-cocoon2-cvs@apache.org Subject: cvs commit: xml-cocoon2/src/org/apache/cocoon Cocoon.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 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 Pierpaolo Fumagalli (Apache Software Foundation, Exoffice Technologies) * @author Stefano Mazzocchi * @author Leo Sutic - * @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 Cocoon 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 boolean 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