Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 82396 invoked by uid 500); 29 May 2002 10:24:21 -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 82387 invoked by uid 500); 29 May 2002 10:24:21 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Date: 29 May 2002 10:24:19 -0000 Message-ID: <20020529102419.97698.qmail@icarus.apache.org> From: cziegeler@apache.org To: xml-cocoon2-cvs@apache.org Subject: cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl CachingProcessingPipeline.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N cziegeler 02/05/29 03:24:19 Modified: src/documentation cocoon.xconf sitemap.xmap src/java/org/apache/cocoon/caching CacheValidityToSourceValidity.java src/java/org/apache/cocoon/components/pipeline/impl CachingProcessingPipeline.java Log: Fixed some NPEs Corrected documentation build Revision Changes Path 1.15 +2 -2 xml-cocoon2/src/documentation/cocoon.xconf Index: cocoon.xconf =================================================================== RCS file: /home/cvs/xml-cocoon2/src/documentation/cocoon.xconf,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- cocoon.xconf 29 May 2002 08:20:25 -0000 1.14 +++ cocoon.xconf 29 May 2002 10:24:18 -0000 1.15 @@ -29,8 +29,8 @@ - - + + 1.13 +2 -2 xml-cocoon2/src/documentation/sitemap.xmap Index: sitemap.xmap =================================================================== RCS file: /home/cvs/xml-cocoon2/src/documentation/sitemap.xmap,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- sitemap.xmap 29 May 2002 08:20:25 -0000 1.12 +++ sitemap.xmap 29 May 2002 10:24:18 -0000 1.13 @@ -39,8 +39,8 @@ - - + 1.4 +12 -2 xml-cocoon2/src/java/org/apache/cocoon/caching/CacheValidityToSourceValidity.java Index: CacheValidityToSourceValidity.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/caching/CacheValidityToSourceValidity.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- CacheValidityToSourceValidity.java 28 May 2002 10:57:42 -0000 1.3 +++ CacheValidityToSourceValidity.java 29 May 2002 10:24:18 -0000 1.4 @@ -58,7 +58,7 @@ * * @since @next-version@ * @author Carsten Ziegeler - * @version CVS $Id: CacheValidityToSourceValidity.java,v 1.3 2002/05/28 10:57:42 cziegeler Exp $ + * @version CVS $Id: CacheValidityToSourceValidity.java,v 1.4 2002/05/29 10:24:18 cziegeler Exp $ */ public final class CacheValidityToSourceValidity implements SourceValidity { @@ -66,9 +66,19 @@ protected CacheValidity cacheValidity; /** + * Create a new instance + */ + public static CacheValidityToSourceValidity createValidity(CacheValidity validity) { + if ( null != validity) { + return new CacheValidityToSourceValidity(validity); + } + return null; + } + + /** * Constructor */ - public CacheValidityToSourceValidity(CacheValidity validity) { + protected CacheValidityToSourceValidity(CacheValidity validity) { this.cacheValidity = validity; } 1.21 +75 -56 xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java Index: CachingProcessingPipeline.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- CachingProcessingPipeline.java 29 May 2002 08:20:26 -0000 1.20 +++ CachingProcessingPipeline.java 29 May 2002 10:24:18 -0000 1.21 @@ -92,7 +92,7 @@ * * @since @next-version@ * @author Carsten Ziegeler - * @version CVS $Id: CachingProcessingPipeline.java,v 1.20 2002/05/29 08:20:26 cziegeler Exp $ + * @version CVS $Id: CachingProcessingPipeline.java,v 1.21 2002/05/29 10:24:18 cziegeler Exp $ */ public class CachingProcessingPipeline extends AbstractProcessingPipeline @@ -251,18 +251,20 @@ this.generator.generate(); } } - if ( this.cacheCompleteResponse ) { - CachedResponse response = new CachedResponse(this.pipelineValidityObjects, - ((CachingOutputStream)os).getContent()); - this.cache.store(environment.getObjectModel(), - this.pipelineCacheKey, - response); - } else { - CachedResponse response = new CachedResponse(this.pipelineValidityObjects, - (byte[])this.xmlSerializer.getSAXFragment()); - this.cache.store(environment.getObjectModel(), - this.pipelineCacheKey, - response); + if (this.pipelineCacheKey != null) { + if ( this.cacheCompleteResponse ) { + CachedResponse response = new CachedResponse(this.pipelineValidityObjects, + ((CachingOutputStream)os).getContent()); + this.cache.store(environment.getObjectModel(), + this.pipelineCacheKey, + response); + } else { + CachedResponse response = new CachedResponse(this.pipelineValidityObjects, + (byte[])this.xmlSerializer.getSAXFragment()); + this.cache.store(environment.getObjectModel(), + this.pipelineCacheKey, + response); + } } } catch ( SocketException se ) { if (se.getMessage().indexOf("reset") > 0 @@ -394,48 +396,44 @@ SourceValidity[] validities = response.getValidityObjects(); int i = 0; while (responseIsValid && i < validities.length) { - boolean isValid = false; - // FIXME (CZ) WORKAROUND validities[i] should never be null - if (validities[i] != null) { - isValid = validities[i].isValid(); - if ( !isValid ) { - final SourceValidity validity; - if (i == 0) { - // test generator - if (generatorIsCacheableProcessingComponent) { - validity = ((CacheableProcessingComponent)super.generator).generateValidity(); - } else { - validity = new CacheValidityToSourceValidity(((Cacheable)super.generator).generateValidity()); - } - } else if (i <= this.firstProcessedTransformerIndex) { - // test transformer - final Transformer trans = - (Transformer)super.transformers.get(i-1); - if (transformerIsCacheableProcessingComponent[i-1]) { - validity = ((CacheableProcessingComponent)trans).generateValidity(); - } else { - validity = new CacheValidityToSourceValidity(((Cacheable)trans).generateValidity()); - } + boolean isValid = validities[i].isValid(); + if ( !isValid ) { + final SourceValidity validity; + if (i == 0) { + // test generator + if (generatorIsCacheableProcessingComponent) { + validity = ((CacheableProcessingComponent)super.generator).generateValidity(); } else { - // test serializer - if (serializerIsCacheableProcessingComponent) { - validity = ((CacheableProcessingComponent)super.serializer).generateValidity(); - } else { - validity = new CacheValidityToSourceValidity(((Cacheable)super.serializer).generateValidity()); - } + validity = CacheValidityToSourceValidity.createValidity(((Cacheable)super.generator).generateValidity()); } - if (validity != null) { - isValid = validities[i].isValid( validity ); + } else if (i <= this.firstProcessedTransformerIndex) { + // test transformer + final Transformer trans = + (Transformer)super.transformers.get(i-1); + if (transformerIsCacheableProcessingComponent[i-1]) { + validity = ((CacheableProcessingComponent)trans).generateValidity(); + } else { + validity = CacheValidityToSourceValidity.createValidity(((Cacheable)trans).generateValidity()); } - if ( !isValid ) { - responseIsValid = false; - // update validity - validities[i] = validity; - if (validity == null) responseIsUsable = false; + } else { + // test serializer + if (serializerIsCacheableProcessingComponent) { + validity = ((CacheableProcessingComponent)super.serializer).generateValidity(); + } else { + validity = CacheValidityToSourceValidity.createValidity(((Cacheable)super.serializer).generateValidity()); } } - if ( isValid ) i++; + if (validity != null) { + isValid = validities[i].isValid( validity ); + } + if ( !isValid ) { + responseIsValid = false; + // update validity + validities[i] = validity; + if (validity == null) responseIsUsable = false; + } } + if ( isValid ) i++; } if ( responseIsValid ) { // we are valid, ok that's it @@ -510,14 +508,16 @@ this.pipelineValidityObjects[i] = cachedValidityObjects[i]; } } - for(int i=start; i < this.pipelineValidityObjects.length; i++) { + int len = this.pipelineValidityObjects.length; + int i = start; + while (i < len) { final SourceValidity validity; if (i == 0) { // test generator if (generatorIsCacheableProcessingComponent) { validity = ((CacheableProcessingComponent)super.generator).generateValidity(); } else { - validity = new CacheValidityToSourceValidity(((Cacheable)super.generator).generateValidity()); + validity = CacheValidityToSourceValidity.createValidity(((Cacheable)super.generator).generateValidity()); } } else if (i <= firstNotCacheableTransformerIndex) { // test transformer @@ -526,17 +526,36 @@ if (transformerIsCacheableProcessingComponent[i-1]) { validity = ((CacheableProcessingComponent)trans).generateValidity(); } else { - validity = new CacheValidityToSourceValidity(((Cacheable)trans).generateValidity()); + validity = CacheValidityToSourceValidity.createValidity(((Cacheable)trans).generateValidity()); } } else { // test serializer if (serializerIsCacheableProcessingComponent) { validity = ((CacheableProcessingComponent)super.serializer).generateValidity(); } else { - validity = new CacheValidityToSourceValidity(((Cacheable)super.serializer).generateValidity()); + validity = CacheValidityToSourceValidity.createValidity(((Cacheable)super.serializer).generateValidity()); + } + } + if (validity == null) { + if (i > 0 && i > cachedPipelineKey.size()) { + // shorten key + for(int m=i; m < this.pipelineValidityObjects.length; m++) { + this.pipelineCacheKey.removeLastKey(); + } + SourceValidity[] copy = new SourceValidity[i]; + System.arraycopy(this.pipelineValidityObjects, 0, + copy, 0, copy.length); + this.pipelineValidityObjects = copy; + len = this.pipelineValidityObjects.length; + } else { + this.pipelineCacheKey = null; + this.pipelineValidityObjects = null; + len = 0; } + } else { + this.pipelineValidityObjects[i] = validity; } - this.pipelineValidityObjects[i] = validity; + i++; } } } @@ -663,7 +682,7 @@ } else { CacheValidity cv = ((Cacheable)super.reader).generateValidity(); if ( cv != null ) { - readerValidity = new CacheValidityToSourceValidity( cv ); + readerValidity = CacheValidityToSourceValidity.createValidity( cv ); } } if (readerValidity != null) { @@ -703,7 +722,7 @@ } else { CacheValidity cv = ((Cacheable)super.reader).generateValidity(); if ( cv != null ) { - readerValidity = new CacheValidityToSourceValidity( cv ); + readerValidity = CacheValidityToSourceValidity.createValidity( cv ); } } } ---------------------------------------------------------------------- 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