cziegeler 2003/05/30 02:23:14
Modified: . status.xml
src/java/org/apache/cocoon/components/pipeline/impl
AbstractCachingProcessingPipeline.java
src/java/org/apache/cocoon/components/source/impl
SitemapSource.java
src/java/org/apache/cocoon/components/pipeline
AbstractProcessingPipeline.java
ProcessingPipeline.java
Log:
Fixing bug 17623
Revision Changes Path
1.45 +4 -1 cocoon-2.1/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/status.xml,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- status.xml 27 May 2003 12:09:01 -0000 1.44
+++ status.xml 30 May 2003 09:23:14 -0000 1.45
@@ -179,7 +179,10 @@
<changes>
- <release version="@version@" date="@date@">
+ <release version="@version@" date="@date@">
+ <action dev="CZ" type="fix" fixes-bug="17623" due-to="Alex Romayev"
due-to-email="[EMAIL PROTECTED]">
+ Fixing incorrect caching behaviour when internal pipelines are used.
+ </action>
<action dev="JT" type="fix">
Command-line will no longer add a 'null' suffix to files with an unknown MIME
type.
</action>
1.6 +32 -5
cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
Index: AbstractCachingProcessingPipeline.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractCachingProcessingPipeline.java 3 May 2003 18:34:41 -0000 1.5
+++ AbstractCachingProcessingPipeline.java 30 May 2003 09:23:14 -0000 1.6
@@ -69,6 +69,7 @@
import org.apache.cocoon.components.sax.XMLSerializer;
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;
@@ -863,11 +864,20 @@
* Otherwise return <code>null</code>
*/
public SourceValidity getValidityForEventPipeline() {
- if ( null != this.toCacheKey
- && !this.completeResponseIsCached
+ int vals = 0;
+
+ if ( null != this.toCacheKey
+ && !this.cacheCompleteResponse
&& this.firstNotCacheableTransformerIndex ==
super.transformers.size()) {
- AggregatedValidity validity = new AggregatedValidity();
- for(int i=0; i < this.toCacheKey.size(); i++) {
+ vals = this.toCacheKey.size();
+ } else if ( null != this.fromCacheKey
+ && !this.completeResponseIsCached
+ && this.firstProcessedTransformerIndex ==
super.transformers.size()) {
+ vals = this.fromCacheKey.size();
+ }
+ if ( vals > 0 ) {
+ final AggregatedValidity validity = new AggregatedValidity();
+ for(int i=0; i < vals; i++) {
validity.add(this.getValidityForInternalPipeline(i));
//validity.add(new DeferredPipelineValidity(this, i));
}
@@ -876,6 +886,23 @@
return null;
}
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.components.pipeline.ProcessingPipeline#getKeyForEventPipeline()
+ */
+ public String getKeyForEventPipeline() {
+ if ( null != this.toCacheKey
+ && !this.cacheCompleteResponse
+ && this.firstNotCacheableTransformerIndex ==
super.transformers.size()) {
+ return String.valueOf(HashUtil.hash(this.toCacheKey.toString()));
+ }
+ if ( null != this.fromCacheKey
+ && !this.completeResponseIsCached
+ && this.firstProcessedTransformerIndex == super.transformers.size()) {
+ return String.valueOf(HashUtil.hash(this.fromCacheKey.toString()));
+ }
+ return null;
+ }
+
/**
*
* @see
org.apache.cocoon.components.pipeline.ProcessingPipeline#getValidityForInternalPipeline(int)
1.5 +25 -2
cocoon-2.1/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
Index: SitemapSource.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SitemapSource.java 20 May 2003 00:50:06 -0000 1.4
+++ SitemapSource.java 30 May 2003 09:23:14 -0000 1.5
@@ -101,6 +101,9 @@
/** The system id */
private String systemId;
+ /** The system id used for caching */
+ private String systemIdForCaching;
+
/** The uri */
private String uri;
@@ -291,7 +294,13 @@
* Return the unique identifer for this source
*/
public String getURI() {
- return this.systemId;
+ if (this.needsRefresh) {
+ this.refresh();
+ }
+ if (this.redirectSource != null) {
+ return this.systemId;
+ }
+ return this.systemIdForCaching;
}
/**
@@ -358,6 +367,20 @@
this.pipelineProcessor);
this.processingPipeline.prepareInternal(this.environment);
this.sourceValidity =
this.processingPipeline.getValidityForEventPipeline();
+ final String eventPipelineKey =
this.processingPipeline.getKeyForEventPipeline();
+ if ( eventPipelineKey != null ) {
+ StringBuffer buffer = new StringBuffer(this.systemId);
+ if ( this.systemId.indexOf('?') == -1) {
+ buffer.append('?');
+ } else {
+ buffer.append('&');
+ }
+ buffer.append("pipelinehash=");
+ buffer.append(eventPipelineKey);
+ this.systemIdForCaching = buffer.toString();
+ } else {
+ this.systemIdForCaching = this.systemId;
+ }
} finally {
CocoonComponentManager.leaveEnvironment();
envStack.resetOffset(currentOffset);
1.4 +8 -1
cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java
Index: AbstractProcessingPipeline.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbstractProcessingPipeline.java 18 May 2003 18:37:09 -0000 1.3
+++ AbstractProcessingPipeline.java 30 May 2003 09:23:14 -0000 1.4
@@ -762,4 +762,11 @@
return expires;
}
+ /* (non-Javadoc)
+ * @see
org.apache.cocoon.components.pipeline.ProcessingPipeline#getKeyForEventPipeline()
+ */
+ public String getKeyForEventPipeline() {
+ return null;
+ }
+
}
1.3 +9 -2
cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java
Index: ProcessingPipeline.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ProcessingPipeline.java 12 Mar 2003 09:10:07 -0000 1.2
+++ ProcessingPipeline.java 30 May 2003 09:23:14 -0000 1.3
@@ -182,5 +182,12 @@
* Otherwise return <code>null</code>
*/
SourceValidity getValidityForEventPipeline();
-
+
+ /**
+ * Return the key for the event pipeline
+ * If the "event pipeline" (= the complete pipeline without the
+ * serializer) is cacheable and valid, return a key.
+ * Otherwise return <code>null</code>
+ */
+ String getKeyForEventPipeline();
}