cziegeler 01/04/17 08:00:28
Modified: src/org/apache/cocoon Tag: xml-cocoon2 Cocoon.java
src/org/apache/cocoon/components/language/markup/sitemap/java
Tag: xml-cocoon2 sitemap.xsl
src/org/apache/cocoon/sitemap Tag: xml-cocoon2 Manager.java
webapp Tag: xml-cocoon2 cocoon.xconf
webapp/WEB-INF Tag: xml-cocoon2 web.xml
xdocs Tag: xml-cocoon2 sitemap.xml
Log:
Added reload-method and check-reload to sitemap configuration
Revision Changes Path
No revision
No revision
1.4.2.73 +19 -4 xml-cocoon/src/org/apache/cocoon/Cocoon.java
Index: Cocoon.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Cocoon.java,v
retrieving revision 1.4.2.72
retrieving revision 1.4.2.73
diff -u -r1.4.2.72 -r1.4.2.73
--- Cocoon.java 2001/04/12 16:00:54 1.4.2.72
+++ Cocoon.java 2001/04/17 15:00:06 1.4.2.73
@@ -52,7 +52,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
(Apache Software Foundation, Exoffice Technologies)
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.4.2.72 $ $Date: 2001/04/12 16:00:54 $
+ * @version CVS $Revision: 1.4.2.73 $ $Date: 2001/04/17 15:00:06 $
*/
public class Cocoon extends AbstractLoggable implements Component,
Initializable, Disposable, Modifiable, Processor, Contextualizable {
/** The application context */
@@ -76,6 +76,12 @@
/** The working directory (null if not available) */
private File workDir;
+ /** Check reloading of sitemap */
+ private boolean checkSitemapReload = true;
+
+ /** reload sitemap asynchron */
+ private boolean reloadSitemapAsynchron = true;
+
/** The component manager. */
private DefaultComponentManager componentManager;
@@ -199,7 +205,13 @@
getLogger().error("No sitemap file name");
throw new ConfigurationException("No sitemap file name\n" +
conf.toString());
}
+ String value = sconf.getAttribute("check-reload", "yes");
+ this.checkSitemapReload = !(value != null &&
value.equalsIgnoreCase("no") == true);
+ value = sconf.getAttribute("reload-method", "asynchron");
+ this.reloadSitemapAsynchron = !(value != null &&
value.equalsIgnoreCase("synchron") == true);
getLogger().debug("Sitemap location = " + this.sitemapFileName);
+ getLogger().debug("Checking sitemap reload = " +
this.checkSitemapReload);
+ getLogger().debug("Reloading sitemap asynchron = " +
this.reloadSitemapAsynchron);
}
/** Queries the class to estimate its ergodic period termination. */
@@ -243,17 +255,20 @@
public boolean process(Environment environment)
throws Exception {
if (disposed) throw new IllegalStateException("You cannot process a
Disposed Cocoon engine.");
- return this.sitemapManager.invoke(environment, "",
this.sitemapFileName, true);
+ return this.sitemapManager.invoke(environment, "",
this.sitemapFileName,
+ this.checkSitemapReload, this.reloadSitemapAsynchron);
}
/**
- * Process the given <code>Environment</code> to assemble
+ * Process the given <code>Environment</code> to assemble
* a <code>StreamPipeline</code> and an <code>EventPipeline</code>.
*/
public boolean process(Environment environment, StreamPipeline pipeline,
EventPipeline eventPipeline)
throws Exception {
if (disposed) throw new IllegalStateException("You cannot process a
Disposed Cocoon engine.");
- return this.sitemapManager.invoke(environment, "",
this.sitemapFileName, true, pipeline, eventPipeline);
+ return this.sitemapManager.invoke(environment, "",
this.sitemapFileName,
+ this.checkSitemapReload, this.reloadSitemapAsynchron,
+ pipeline, eventPipeline);
}
/**
No revision
No revision
1.1.2.97 +18 -3
xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl
Index: sitemap.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl,v
retrieving revision 1.1.2.96
retrieving revision 1.1.2.97
diff -u -r1.1.2.96 -r1.1.2.97
--- sitemap.xsl 2001/04/17 13:20:54 1.1.2.96
+++ sitemap.xsl 2001/04/17 15:00:11 1.1.2.97
@@ -96,7 +96,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo
Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin
Loritsch</a>
- * @version CVS $Id: sitemap.xsl,v 1.1.2.96 2001/04/17 13:20:54 dims Exp
$
+ * @version CVS $Id: sitemap.xsl,v 1.1.2.97 2001/04/17 15:00:11
cziegeler Exp $
*/
public class <xsl:value-of select="@file-name"/> extends AbstractSitemap
{
static final String LOCATION = "<xsl:value-of
select="translate(@file-path, '/', '.')"/>.<xsl:value-of select="@file-name"/>";
@@ -900,11 +900,26 @@
</xsl:choose>
</xsl:variable>
+ <xsl:variable name="reload-method">
+ <xsl:choose>
+ <xsl:when test="@reload-method='asynchron'">true</xsl:when>
+ <xsl:when test="@reload-method='synchron'">false</xsl:when>
+ <xsl:when test="not(@reload-method)">true</xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="error">
+ <xsl:with-param name="message">
+ element <xsl:value-of select="name(.)"/> with
uri-prefix="<xsl:value-of select="@uri-prefix"/>" has a wrong value in
'reload-method' attribute . Use "asynchron" or "synchron" but not
"<xsl:value-of select="@reload-method"/>".
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
<!-- generate the code to invoke the sitemapManager which handles
delegation of control to sub sitemaps -->
if (internalRequest)
- return sitemapManager.invoke (environment,
substitute(listOfMaps,"<xsl:value-of select="@uri-prefix"/>"),
substitute(listOfMaps,"<xsl:value-of select="@src"/>"), <xsl:value-of
select="$check-reload"/>, pipeline, eventPipeline);
+ return sitemapManager.invoke (environment,
substitute(listOfMaps,"<xsl:value-of select="@uri-prefix"/>"),
substitute(listOfMaps,"<xsl:value-of select="@src"/>"), <xsl:value-of
select="$check-reload"/>, <xsl:value-of select="$reload-method"/>, pipeline,
eventPipeline);
else
- if(true)return sitemapManager.invoke (environment,
substitute(listOfMaps,"<xsl:value-of select="@uri-prefix"/>"),
substitute(listOfMaps,"<xsl:value-of select="@src"/>"), <xsl:value-of
select="$check-reload"/>);
+ if(true)return sitemapManager.invoke (environment,
substitute(listOfMaps,"<xsl:value-of select="@uri-prefix"/>"),
substitute(listOfMaps,"<xsl:value-of select="@src"/>"), <xsl:value-of
select="$check-reload"/>, <xsl:value-of select="$reload-method"/>);
</xsl:template> <!-- match="map:mount" -->
<!-- generate the code to redirect a request -->
No revision
No revision
1.1.2.14 +30 -20
xml-cocoon/src/org/apache/cocoon/sitemap/Attic/Manager.java
Index: Manager.java
===================================================================
RCS file:
/home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/Manager.java,v
retrieving revision 1.1.2.13
retrieving revision 1.1.2.14
diff -u -r1.1.2.13 -r1.1.2.14
--- Manager.java 2001/04/16 16:04:44 1.1.2.13
+++ Manager.java 2001/04/17 15:00:15 1.1.2.14
@@ -23,6 +23,7 @@
import org.apache.avalon.Loggable;
import org.apache.avalon.AbstractLoggable;
+import org.apache.cocoon.Constants;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.pipeline.StreamPipeline;
import org.apache.cocoon.components.pipeline.EventPipeline;
@@ -38,7 +39,7 @@
* checking regeneration of the sub <code>Sitemap</code>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
- * @version CVS $Revision: 1.1.2.13 $ $Date: 2001/04/16 16:04:44 $
+ * @version CVS $Revision: 1.1.2.14 $ $Date: 2001/04/17 15:00:15 $
*/
public class Manager extends AbstractLoggable implements Configurable,
Composer, Contextualizable {
@@ -55,21 +56,21 @@
/** get a configuration
* @param conf the configuration
- */
+ */
public void configure (Configuration conf) {
this.conf = conf;
}
/** get a context
* @param context the context object
- */
+ */
public void contextualize (Context context) {
this.context = context;
}
/** get a component manager
* @param manager the component manager
- */
+ */
public void compose (ComponentManager manager) {
this.manager = manager;
}
@@ -79,18 +80,19 @@
* @param uri_prefix the prefix to the URI
* @param source the source of the sitemap
* @param check_reload should the sitemap be automagically reloaded
+ * @param reload_asynchron should the sitemap be reloaded asynchron
* @throws Exception there may be several excpetions thrown
* @return states if the requested resource was produced
- */
+ */
public boolean invoke (Environment environment, String uri_prefix,
- String source, boolean check_reload)
+ String source, boolean check_reload, boolean
reload_asynchron)
throws Exception {
-
+
// make sure the uri_prefix ends with a slash
String prefix = this.getPrefix(uri_prefix);
// get a sitemap handler
- Handler sitemapHandler = getHandler(environment, source,
check_reload);
+ Handler sitemapHandler = getHandler(environment, source,
check_reload, reload_asynchron);
// setup to invoke the processing
setupProcessing(environment, sitemapHandler, uri_prefix, source);
@@ -102,19 +104,20 @@
* @param uri_prefix the prefix to the URI
* @param source the source of the sitemap
* @param check_reload should the sitemap be automagically reloaded
+ * @param reload_asynchron should the sitemap be reloaded asynchron
* @throws Exception there may be several excpetions thrown
* @return states if the requested resource was produced
- */
+ */
public boolean invoke (Environment environment, String uri_prefix,
- String source, boolean check_reload,
+ String source, boolean check_reload, boolean
reload_asynchron,
StreamPipeline pipeline, EventPipeline
eventPipeline)
throws Exception {
-
+
// make sure the uri_prefix ends with a slash
String prefix = this.getPrefix(uri_prefix);
-
+
// get a sitemap handler
- Handler sitemapHandler = getHandler(environment, source,
check_reload);
+ Handler sitemapHandler = getHandler(environment, source,
check_reload, reload_asynchron);
// setup to invoke the processing
setupProcessing(environment, sitemapHandler, uri_prefix, source);
@@ -123,7 +126,7 @@
/** has the sitemap changed
* @return whether the sitemap file has changed
- */
+ */
public boolean hasChanged() {
Handler sitemapHandler = null;
Iterator iter = sitemaps.values().iterator();
@@ -135,7 +138,7 @@
}
return false;
}
-
+
/** make sure the uri_prefix ends with a slash */
private String getPrefix (String uri_prefix) {
if (uri_prefix.length() > 0)
@@ -143,17 +146,24 @@
else
return uri_prefix;
}
-
- private Handler getHandler(final Environment environment, final String
source, final boolean check_reload)
+
+ private Handler getHandler(final Environment environment,
+ final String source,
+ final boolean check_reload,
+ final boolean reload_asynchron)
throws Exception {
Handler sitemapHandler = (Handler) sitemaps.get(source);
-
+
if (sitemapHandler != null) {
if (sitemapHandler.available()) {
if (check_reload
&& sitemapHandler.hasChanged()
&& !sitemapHandler.isRegenerating()) {
- sitemapHandler.regenerateAsynchronously(environment);
+ if (reload_asynchron == true) {
+ sitemapHandler.regenerateAsynchronously(environment);
+ } else {
+ sitemapHandler.regenerate(environment);
+ }
}
} else {
sitemapHandler.regenerate(environment);
@@ -170,7 +180,7 @@
return sitemapHandler;
}
- private void setupProcessing (Environment environment, Handler
sitemapHandler, String uri_prefix, String source)
+ private void setupProcessing (Environment environment, Handler
sitemapHandler, String uri_prefix, String source)
throws Exception {
environment.changeContext(uri_prefix, source);
if (! sitemapHandler.available())
No revision
No revision
1.1.2.38 +19 -1 xml-cocoon/webapp/Attic/cocoon.xconf
Index: cocoon.xconf
===================================================================
RCS file: /home/cvs/xml-cocoon/webapp/Attic/cocoon.xconf,v
retrieving revision 1.1.2.37
retrieving revision 1.1.2.38
diff -u -r1.1.2.37 -r1.1.2.38
--- cocoon.xconf 2001/04/12 21:12:39 1.1.2.37
+++ cocoon.xconf 2001/04/17 15:00:19 1.1.2.38
@@ -107,5 +107,23 @@
<!-- ======================== The sitemap ============================== -->
- <sitemap file="sitemap.xmap"/>
+ <!-- The reloading of the sitemap:
+ The check-reload attribute determines if the sitemap is reloaded on
change. If
+ it is set to "no", the sitemap is generated once at startup, if it
is set to "yes",
+ the sitemap is regenerated if it changes.
+ The reload-method specifies the method for the regeneration:
+ asynchron: If the sitemap changes, the sitemap is regenerated at the
next request in
+ the background and the incoming request is served
with the old sitemap.
+ All subsequent requests are served with the old
sitemap until the
+ regeneration in the background has finished.
+ synchron: If the sitemap changes, the sitemap is regenerated at the
next request.
+ When the regeneration is finished the request (and
all subsequent ones)
+ is served with the new sitemap.
+
+ For development environment set the reload-method to synchron and the
+ check-reload to yes, for production environment it is advisable to
set
+ the reload-method to asynchron and for more safety the check-reload
to no.
+ -->
+ <sitemap file="sitemap.xmap" reload-method="asynchron" check-reload="yes"/>
+
</cocoon>
No revision
No revision
1.1.2.17 +6 -0 xml-cocoon/webapp/WEB-INF/Attic/web.xml
Index: web.xml
===================================================================
RCS file: /home/cvs/xml-cocoon/webapp/WEB-INF/Attic/web.xml,v
retrieving revision 1.1.2.16
retrieving revision 1.1.2.17
diff -u -r1.1.2.16 -r1.1.2.17
--- web.xml 2001/04/09 14:11:00 1.1.2.16
+++ web.xml 2001/04/17 15:00:22 1.1.2.17
@@ -27,10 +27,16 @@
<param-name>log-level</param-name>
<param-value>DEBUG</param-value>
</init-param>
+
+ <!-- Allow reinstantiating (reloading) of the cocoon instance. If this is
+ set to yes, a new cocoon instance can be created using
+ the request parameter "cocoon-reload".
+ -->
<init-param>
<param-name>allow-reload</param-name>
<param-value>yes</param-value>
</init-param>
+
<init-param>
<param-name>load-class</param-name>
<param-value>
No revision
No revision
1.1.2.9 +23 -1 xml-cocoon/xdocs/Attic/sitemap.xml
Index: sitemap.xml
===================================================================
RCS file: /home/cvs/xml-cocoon/xdocs/Attic/sitemap.xml,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- sitemap.xml 2001/03/26 08:54:16 1.1.2.8
+++ sitemap.xml 2001/04/17 15:00:26 1.1.2.9
@@ -8,6 +8,7 @@
<authors>
<person name="Giacomo Pati" email="[EMAIL PROTECTED]"/>
<person name="Stefano Mazzocchi" email="[EMAIL PROTECTED]"/>
+ <person name="Carsten Ziegeler" email="[EMAIL PROTECTED]"/>
</authors>
</header>
@@ -501,7 +502,7 @@
SitemapComponentManager and can ask it for a SitemapComponent it
doesn't know about.
</p>
</s3>
- <s3 title="Usage Cases">
+ <s3 title="Use Cases">
<p>
Usually you use the same SitemapComponents over and over again in your
sub-sitemaps.
And because you have a contract between the parent and sub sitemaps
(the uri-prefix) you
@@ -567,6 +568,27 @@
</map:sitemap>
]]>
</source>
+ </s3>
+ <s3 title="Reloading">
+ <p>The reloading of the subsitemaps can be configured by two
attributes. </p>
+ <source>
+<![CDATA[
+ <map:match pattern="faq/*">
+ <map:mount uri-prefix="faq/" check-reload="no" src="faq/sitemap.xmap"
reload-method="asynchron"/>
+ </map:match>
+]]>
+ </source>
+ <p>
+ The "check-reload" attribute specifies if the sitemap is reloaded, this
means regenerated, if
+ it changes. If it set to "no", the sitemap is only generated on the
first request for this
+ sitemap.
+ If it is set to "yes" (the default), the reload-method determines who
the sitemap is regenerated
+ if it had changed. If it set to "asynchron" (the default), the next
request for the changed
+ sitemap, regenerates the sitemap in the background and the request is
served with the old
+ one. All subsequent requests are served with the old sitemap until the
regeneration in the
+ background has finished. If the reload-method is set to "synchron", the
sitemap is first
+ regenerated and then the request is responded.
+ </p>
</s3>
</s2>
</s1>
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]