You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by gi...@apache.org on 2001/12/09 22:36:42 UTC
cvs commit: xml-cocoon2/webapp cocoon.xconf
giacomo 01/12/09 13:36:42
Modified: src/org/apache/cocoon cocoon.roles
src/org/apache/cocoon/components/language/generator
ProgramGeneratorImpl.java
webapp cocoon.xconf
Log:
Added Resource Monitor in ProgramGeneratorImpl
Submitted by: Gerhard Froehlich <g-...@gmx.de>
Revision Changes Path
1.31 +4 -0 xml-cocoon2/src/org/apache/cocoon/cocoon.roles
Index: cocoon.roles
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/cocoon.roles,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- cocoon.roles 2001/12/07 10:12:10 1.30
+++ cocoon.roles 2001/12/09 21:36:42 1.31
@@ -173,4 +173,8 @@
shorthand="reader"
default-class="org.apache.cocoon.sitemap.SitemapComponentSelector"/>
+ <role name="org.apache.avalon.excalibur.monitor.Monitor"
+ shorthand="monitor"
+ default-class="org.apache.avalon.excalibur.monitor.ActiveMonitor"/>
+
</role-list>
1.24 +41 -3 xml-cocoon2/src/org/apache/cocoon/components/language/generator/ProgramGeneratorImpl.java
Index: ProgramGeneratorImpl.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/generator/ProgramGeneratorImpl.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- ProgramGeneratorImpl.java 2001/10/30 15:38:21 1.23
+++ ProgramGeneratorImpl.java 2001/12/09 21:36:42 1.24
@@ -8,6 +8,8 @@
package org.apache.cocoon.components.language.generator;
+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.component.*;
import org.apache.avalon.framework.configuration.Configurable;
@@ -31,18 +33,23 @@
import org.apache.cocoon.environment.Source;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.util.IOUtils;
+import org.apache.cocoon.util.NetUtils;
import org.xml.sax.InputSource;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeEvent;
import java.io.File;
+import java.net.URL;
import java.net.MalformedURLException;
/**
* The default implementation of <code>ProgramGenerator</code>
* @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
- * @version CVS $Revision: 1.23 $ $Date: 2001/10/30 15:38:21 $
+ * @version CVS $Revision: 1.24 $ $Date: 2001/12/09 21:36:42 $
*/
public class ProgramGeneratorImpl extends AbstractLoggable
- implements ProgramGenerator, Contextualizable, Composable, Configurable, ThreadSafe, Disposable {
+ implements ProgramGenerator, Contextualizable, Composable, Configurable, ThreadSafe,
+ Disposable, PropertyChangeListener {
/** The auto-reloading option */
protected boolean autoReload = false;
@@ -77,6 +84,15 @@
/** Servlet Context Directory */
protected String contextDir;
+ /** Resource monitoring */
+ protected Monitor monitor;
+
+ /** lastModified date */
+ protected long lastModified;
+
+ /** File resource */
+ protected FileResource file;
+
/** Contextualize this class */
public void contextualize(Context context) throws ContextException {
if (this.workDir == null) {
@@ -111,6 +127,7 @@
this.markupSelector = (ComponentSelector)this.manager.lookup(MarkupLanguage.ROLE + "Selector");
this.languageSelector = (ComponentSelector)this.manager.lookup(ProgrammingLanguage.ROLE + "Selector");
this.classManager = (ClassLoaderManager)this.manager.lookup(ClassLoaderManager.ROLE);
+ this.monitor = (Monitor) this.manager.lookup(Monitor.ROLE);
} catch (Exception e) {
getLogger().warn("Could not lookup Component", e);
}
@@ -145,6 +162,15 @@
throws Exception {
Source source = resolver.resolve(fileName);
+
+ /** Monitoring the Sitemap source */
+ URL url = new URL(source.getSystemId());
+ getLogger().debug("Sitemap path=" + url.getFile());
+ file = new FileResource(url.getFile());
+ file.addPropertyChangeListener(this);
+ monitor.addResource(file);
+ getLogger().debug("lastModified date=" + this.getLastModified());
+
try {
// Set filenames
StringBuffer contextFilename = new StringBuffer(this.rootPackage.replace('.', File.separatorChar));
@@ -200,7 +226,7 @@
* be queried for changes!!!
*/
- if (programInstance != null && programInstance.modifiedSince(source.getLastModified())) {
+ if (programInstance != null && programInstance.modifiedSince(this.getLastModified())) {
// Release the component.
release(programInstance);
@@ -363,5 +389,17 @@
this.manager.release((Component)this.repository);
this.manager.release((Component)this.markupSelector);
this.manager.release((Component)this.languageSelector);
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ setLastModified(((Long)evt.getNewValue()).longValue());
+ }
+
+ private void setLastModified(long _lastModified) {
+ lastModified = _lastModified;
+ }
+
+ private long getLastModified() {
+ return lastModified;
}
}
1.43 +7 -0 xml-cocoon2/webapp/cocoon.xconf
Index: cocoon.xconf
===================================================================
RCS file: /home/cvs/xml-cocoon2/webapp/cocoon.xconf,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- cocoon.xconf 2001/11/28 08:40:07 1.42
+++ cocoon.xconf 2001/12/09 21:36:42 1.43
@@ -434,6 +434,13 @@
<profiler/>
-->
+ <!-- Resource Monitor:
+ The Monitor keeps track on changes to a Resource.
+ -->
+ <monitor>
+ <thread priority="5" frequency="10000"/>
+ </monitor>
+
<!-- ======================== The sitemap ============================== -->
<!-- Reloading of the sitemap:
----------------------------------------------------------------------
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