You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by jb...@apache.org on 2006/02/23 17:28:46 UTC
svn commit: r380147 - in /cocoon/branches/BRANCH_2_1_X:
src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
src/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java
status.xml
Author: jbq
Date: Thu Feb 23 08:28:41 2006
New Revision: 380147
URL: http://svn.apache.org/viewcvs?rev=380147&view=rev
Log:
Fix COCOON-1279
Modified:
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java
cocoon/branches/BRANCH_2_1_X/status.xml
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java?rev=380147&r1=380146&r2=380147&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java Thu Feb 23 08:28:41 2006
@@ -15,10 +15,16 @@
*/
package org.apache.cocoon.components.pipeline.impl;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameters;
-
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.caching.CacheValidity;
import org.apache.cocoon.caching.CacheValidityToSourceValidity;
@@ -31,20 +37,12 @@
import org.apache.cocoon.environment.Environment;
import org.apache.cocoon.transformation.Transformer;
import org.apache.cocoon.util.HashUtil;
-
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.validity.AggregatedValidity;
import org.apache.excalibur.source.impl.validity.DeferredValidity;
import org.apache.excalibur.source.impl.validity.NOPValidity;
import org.apache.excalibur.store.Store;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Date;
-
/**
* This is the base class for all caching pipeline implementations
* that check different pipeline components.
@@ -98,12 +96,6 @@
protected boolean generatorIsCacheableProcessingComponent;
protected boolean serializerIsCacheableProcessingComponent;
protected boolean[] transformerIsCacheableProcessingComponent;
-
- /** Smart caching ? */
- protected boolean doSmartCaching;
-
- /** Default setting for smart caching */
- protected boolean configuredDoSmartCaching;
protected Store transientStore = null;
@@ -129,8 +121,6 @@
public void parameterize(Parameters params)
throws ParameterException {
super.parameterize(params);
- this.configuredDoSmartCaching =
- params.getParameterAsBoolean("smart-caching", true);
String storeRole = params.getParameter("store-role",Store.TRANSIENT_STORE);
@@ -144,15 +134,6 @@
}
/**
- * Setup this component
- */
- public void setup(Parameters params) {
- super.setup(params);
- this.doSmartCaching = params.getParameterAsBoolean("smart-caching",
- this.configuredDoSmartCaching);
- }
-
- /**
* Set the generator.
*/
public void setGenerator (String role, String source, Parameters param,
@@ -715,25 +696,18 @@
);
}
- if (!this.doSmartCaching) {
- // try a shorter key
- if (this.fromCacheKey.size() > 1) {
- this.fromCacheKey.removeLastKey();
- if (!this.completeResponseIsCached) {
- this.firstProcessedTransformerIndex--;
- }
- finished = false;
- } else {
- this.fromCacheKey = null;
- }
- } else {
- // stop on longest key for smart caching
- this.fromCacheKey = null;
- }
+ finished = setupFromCacheKey();
+
this.completeResponseIsCached = false;
}
}
+ }
+
+ boolean setupFromCacheKey() {
+ // stop on longest key for smart caching
+ this.fromCacheKey = null;
+ return true;
}
/**
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java?rev=380147&r1=380146&r2=380147&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java Thu Feb 23 08:28:41 2006
@@ -38,7 +38,9 @@
import java.util.ListIterator;
/**
- * The CachingPointProcessingPipeline
+ * The caching-point pipeline implements an extended caching algorithm which is
+ * of particular benefit for use with those pipelines that utilise cocoon-views
+ * and/or provide drill-down functionality.
*
* @since 2.1
* @author <a href="mailto:Michael.Melhem@managesoft.com">Michael Melhem</a>
@@ -55,11 +57,28 @@
/**
* The <code>CachingPointProcessingPipeline</code> is configurable.
- * The autoCachingPoint algorithm can be switced on/off
- * in the sitemap.xmap
+ *
+ * <p>The autoCachingPoint algorithm (if enabled) will automatically cache
+ * common elements of the pipeline currently being processed - as well as the
+ * entire cacheable pipeline according to the "longest cacheable key"
+ * algorithm. This feature is especially useful for pipelines that branch at
+ * some point (this is the case with <tt><map:select></tt> or
+ * <tt><map:act></tt>).
+ *
+ * <p>The option <tt>autoCachingPoint</tt> can be switched on/off in the
+ * sitemap.xmap (on by default). For linear pipelines, one can switch "Off"
+ * <tt>autoCachingPoint</tt> and use attribute
+ * <tt>pipeline-hints="caching-point"</tt> to manually indicate that certain
+ * pipeline components (eg on <tt><map:generator></tt>) should be
+ * considered as cache points. Both options (automatic at branch points and
+ * manual with pipeline hints) can coexist in the same pipeline.</p>
+ *
+ * <p>Works by requesting the pipeline processor to try shorter keys when
+ * looking for a cached content for the pipeline.</p>
*/
public void parameterize(Parameters config) throws ParameterException {
super.parameterize(config);
+
this.autoCachingPointSwitch = config.getParameter("autoCachingPoint", null);
if (this.getLogger().isDebugEnabled()) {
@@ -131,11 +150,14 @@
}
/**
- * Determine if the given branch-point
- * is a caching-point
+ * Determine if the given branch-point is a caching-point. This is called
+ * by sitemap components when using cocoon views; it is also called by
+ * parent nodes (mainly selectors and actions).
*
* Please Note: this method is used by auto caching-point
* and is of no consequence when auto caching-point is switched off
+ *
+ * @see org.apache.cocoon.components.treeprocessor.SimpleParentProcessingNode
*/
public void informBranchPoint() {
if (this.autoCachingPoint && this.generator != null) {
@@ -375,5 +397,19 @@
this.xmlSerializerArray.clear();
this.nextIsCachePoint = false;
this.autoCachingPointSwitch=null;
+ }
+
+ boolean setupFromCacheKey() {
+ // try a shorter key
+ if (this.fromCacheKey.size() > 1) {
+ this.fromCacheKey.removeLastKey();
+ if (!this.completeResponseIsCached) {
+ this.firstProcessedTransformerIndex--;
+ }
+ return false;
+ } else {
+ this.fromCacheKey = null;
+ return true;
+ }
}
}
Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?rev=380147&r1=380146&r2=380147&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Thu Feb 23 08:28:41 2006
@@ -180,6 +180,9 @@
<release version="@version@" date="@date@">
-->
<release version="2.1.9" date="TBD">
+ <action dev="JBQ" type="fix" fixes-bug="COCOON-1279">
+ Fix caching-point pipelines. Remove the undocumented smart-caching parameter.
+ </action>
<action dev="JBQ" type="fix" fixes-bug="COCOON-1066" due-to="Antonio Fiol" due-to-email="antonio.fiol@gmail.com">
LDAPTransformer can optionally output the DN of every returned entry as an
attribute. To enable, use <ldap:dn-attribute>dn</ldap:dn-attribute>