Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 84349 invoked by uid 500); 2 May 2002 14:20:47 -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 84340 invoked by uid 500); 2 May 2002 14:20:47 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Date: 2 May 2002 14:20:46 -0000 Message-ID: <20020502142046.77922.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 CachingProcessingPipeline.java NonCachingProcessingPipeline.java AbstractProcessingPipeline.java NonCachingStreamPipeline.java ProcessingPipeline.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N cziegeler 02/05/02 07:20:46 Modified: src/java/org/apache/cocoon/components/pipeline AbstractProcessingPipeline.java NonCachingStreamPipeline.java ProcessingPipeline.java Added: src/java/org/apache/cocoon/components/pipeline CachingProcessingPipeline.java NonCachingProcessingPipeline.java Log: Adding first implementations Revision Changes Path 1.2 +16 -3 xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java Index: AbstractProcessingPipeline.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/AbstractProcessingPipeline.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AbstractProcessingPipeline.java 2 May 2002 09:31:26 -0000 1.1 +++ AbstractProcessingPipeline.java 2 May 2002 14:20:46 -0000 1.2 @@ -95,7 +95,7 @@ * sitemap file). * * @author Carsten Ziegeler - * @version CVS $Id: AbstractProcessingPipeline.java,v 1.1 2002/05/02 09:31:26 cziegeler Exp $ + * @version CVS $Id: AbstractProcessingPipeline.java,v 1.2 2002/05/02 14:20:46 cziegeler Exp $ */ public abstract class AbstractProcessingPipeline extends AbstractLoggable @@ -141,6 +141,9 @@ /** the component manager set with compose() and recompose() */ protected ComponentManager newManager; + /** The parameters */ + protected Parameters parameters; + /** * Composable Interface */ @@ -430,6 +433,14 @@ } /** + * Set the configuration + */ + public void setup(Parameters parameters) + throws ProcessingException { + this.parameters = parameters; + } + + /** * Process the given Environment, producing the output. */ public boolean process(Environment environment) @@ -440,6 +451,8 @@ if ( this.reader != null ) { return this.processReader(environment); } else { + this.setupPipeline(environment); + this.connectPipeline(environment); return this.processXMLPipeline(environment); } } @@ -449,8 +462,6 @@ */ protected boolean processXMLPipeline(Environment environment) throws ProcessingException { - this.setupPipeline(environment); - this.connectPipeline(environment); try { if (this.serializer.shouldSetContentLength()) { @@ -574,5 +585,7 @@ this.manager.release((Component) itc.next()); } this.connectors.clear(); + + this.parameters = null; } } 1.6 +4 -15 xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/NonCachingStreamPipeline.java Index: NonCachingStreamPipeline.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/NonCachingStreamPipeline.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- NonCachingStreamPipeline.java 24 Feb 2002 23:33:12 -0000 1.5 +++ NonCachingStreamPipeline.java 2 May 2002 14:20:46 -0000 1.6 @@ -55,15 +55,11 @@ import java.io.IOException; -/** A ResourcePipeline either - *
    - *
  • collects a Reader and let it process
  • - *
  • or connects a EventPipeline with a - * Serializer and let them produce the requested - * resource - *
+/** + * This is the non caching implementation of a processing pipeline. + * * @author Giacomo Pati - * @version CVS $Id: NonCachingStreamPipeline.java,v 1.5 2002/02/24 23:33:12 dims Exp $ + * @version CVS $Id: NonCachingStreamPipeline.java,v 1.6 2002/05/02 14:20:46 cziegeler Exp $ */ public class NonCachingStreamPipeline extends AbstractStreamPipeline { @@ -82,11 +78,4 @@ super.setupPipeline(environment); } - /** - * Recycle this component - */ - public void recycle() { - getLogger().debug("Recycling of NonCachingStreamPipeline"); - super.recycle(); - } } 1.2 +7 -1 xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java Index: ProcessingPipeline.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/ProcessingPipeline.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ProcessingPipeline.java 2 May 2002 09:31:26 -0000 1.1 +++ ProcessingPipeline.java 2 May 2002 14:20:46 -0000 1.2 @@ -76,7 +76,7 @@ * * @author Carsten Ziegeler * @author Giacomo Pati - * @version CVS $Id: ProcessingPipeline.java,v 1.1 2002/05/02 09:31:26 cziegeler Exp $ + * @version CVS $Id: ProcessingPipeline.java,v 1.2 2002/05/02 14:20:46 cziegeler Exp $ */ public interface ProcessingPipeline extends Component, Recomposable { @@ -134,6 +134,12 @@ * @param mimeType Can be null */ void setReader (String role, String source, Parameters param, String mimeType) + throws ProcessingException; + + /** + * Set the configuration + */ + void setup(Parameters parameters) throws ProcessingException; /** 1.1 xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/CachingProcessingPipeline.java Index: CachingProcessingPipeline.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi . For more information on the Apache Software Foundation, please see . */ package org.apache.cocoon.components.pipeline; import org.apache.avalon.excalibur.pool.Recyclable; import org.apache.avalon.framework.activity.Disposable; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.caching.*; import org.apache.cocoon.components.sax.XMLDeserializer; import org.apache.cocoon.components.sax.XMLSerializer; import org.apache.cocoon.components.sax.XMLTeePipe; import org.apache.cocoon.components.saxconnector.SAXConnector; import org.apache.cocoon.components.store.Store; import org.apache.cocoon.environment.Environment; import org.apache.cocoon.transformation.Transformer; import org.apache.cocoon.xml.XMLConsumer; import org.apache.cocoon.xml.XMLProducer; import org.xml.sax.SAXException; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; /** * The CachingProcessingPipeline * * If all components of this event pipeline are cacheable then the whole * pipeline is also cacheable. If in this case the CacheableEventPipeline interface * is invoked (e.g. by the CachingStreamPipeline) the CachingEventPipeline * does not cache! (If it would cache, the response would be cached twice!) * * @author Carsten Ziegeler * @version CVS $Id: CachingProcessingPipeline.java,v 1.1 2002/05/02 14:20:46 cziegeler Exp $ */ public class CachingProcessingPipeline extends AbstractProcessingPipeline implements Disposable { /** The store for the cached response (or part of the response) */ private Store cache; /** The role name of the generator */ private String generatorRole; /** The role names of the transfomrers */ private ArrayList transformerRoles = new ArrayList(); /** The role name of the serializer */ private String serializerRole; /** The role name of the reader */ private String readerRole; private ArrayList notCacheableTransformers = new ArrayList(); private Map validityObjects; private PipelineCacheKey pipelineCacheKey; private boolean setupFinished = false; /** Indicates if the whole pipeline is cacheable */ private boolean cacheable = false; private int firstNotCacheableTransformerIndex; /** * Composable Interface */ public void compose (ComponentManager manager) throws ComponentException { super.compose(manager); this.cache = (Store)this.manager.lookup(Store.TRANSIENT_CACHE); } /** * Set the generator. */ public void setGenerator (String role, String source, Parameters param) throws ProcessingException { super.setGenerator(role, source, param); this.generatorRole = role; } /** * Add a transformer. */ public void addTransformer (String role, String source, Parameters param) throws ProcessingException { super.addTransformer(role, source, param); this.transformerRoles.add(role); } /** * Set the serializer. */ public void setSerializer (String role, String source, Parameters param, String mimeType) throws ProcessingException { super.setSerializer(role, source, param, mimeType); this.serializerRole = role; } /** * Set the Reader. */ public void setReader (String role, String source, Parameters param, String mimeType) throws ProcessingException { super.setReader(role, source, param, mimeType); this.readerRole = role; } /** * Process the given Environment, producing the output. public boolean process(Environment environment) throws Exception { this.setup(environment); // we cache if the pipelinecachekey is available XMLSerializer xmlSerializer = null; try { if (this.pipelineCacheKey != null) { // now we have the key to get the cached object CachedEventObject cachedObject = (CachedEventObject)this.eventCache.get(this.pipelineCacheKey); if (cachedObject != null) { getLogger().debug("Found cached content for '" + environment.getURI() + "'."); Iterator validityIterator = validityObjects.keySet().iterator(); ComponentCacheKey validityKey; boolean valid = true; while (validityIterator.hasNext() && valid) { validityKey = (ComponentCacheKey)validityIterator.next(); valid = cachedObject.isValid(validityKey, (CacheValidity)validityObjects.get(validityKey)); if (getLogger().isDebugEnabled()) { CacheValidity cachedValidity = cachedObject.getCacheValidity(validityKey); getLogger().debug("Compared cached validity '" + cachedValidity + "' with new validity '" + validityObjects.get(validityKey) + "' : " + (valid ? "valid" : "changed")); } } if (valid) { getLogger().debug("Using valid cached content for '" + environment.getURI() + "'."); // get all transformers which are not cacheable int transformerSize = this.transformers.size(); while (this.firstNotCacheableTransformerIndex < transformerSize) { this.notCacheableTransformers.add(this.transformers.get(this.firstNotCacheableTransformerIndex)); this.firstNotCacheableTransformerIndex++; } XMLDeserializer deserializer = null; try { deserializer = (XMLDeserializer)this.manager.lookup(XMLDeserializer.ROLE); // connect the pipeline: this.producer = deserializer; this.connectPipeline(environment, notCacheableTransformers, null); // execute the pipeline: deserializer.deserialize(cachedObject.getSAXFragment()); } catch ( ProcessingException e ) { throw e; } catch ( Exception e ) { throw new ProcessingException( "Failed to execute pipeline.", e ); } finally { this.manager.release(deserializer); } } else { getLogger().debug("Cached content is invalid for '" + environment.getURI() + "'."); // remove invalid cached object this.eventCache.remove(this.pipelineCacheKey); cachedObject = null; } } if (cachedObject == null) { getLogger().debug("Caching content for further requests of '" + environment.getURI() + "'."); xmlSerializer = (XMLSerializer)this.manager.lookup(XMLSerializer.ROLE); } } if (this.producer == null) { // the content was not cached/or is invalid this.producer = this.generator; this.connectPipeline(environment, this.transformers, xmlSerializer); // execute the pipeline: this.generator.generate(); // did we have cacheable components? if (xmlSerializer != null) { this.eventCache.store(this.pipelineCacheKey, new CachedEventObject(this.validityObjects, xmlSerializer.getSAXFragment())); } } } finally { this.manager.release(xmlSerializer); } return true; } */ /** * Setup the evenet pipeline. * The components of the pipeline are checked if they are * Cacheable. private void setup(Environment environment) throws Exception { if (this.setupFinished) { return; } if (!this.checkPipeline()) { throw new ProcessingException("Attempted to process incomplete pipeline."); } // set up all sitemap components this.setupPipeline(environment); this.firstNotCacheableTransformerIndex = 0; // is the generator cacheable? if (this.generator instanceof Cacheable) { long key = ((Cacheable)this.generator).generateKey(); CacheValidity validity = ((Cacheable)this.generator).generateValidity(); // final check, the current generator might not be cacheable if (key != 0 && validity != null) { ComponentCacheKey cck = new ComponentCacheKey( ComponentCacheKey.ComponentType_Generator, this.generatorRole, key); this.validityObjects = new HashMap(); this.validityObjects.put(cck, validity); this.pipelineCacheKey = new PipelineCacheKey(); this.pipelineCacheKey.addKey(cck); // now testing transformers Transformer trans; ComponentCacheKey transCacheKey; int transformerSize = this.transformers.size(); long transKey; CacheValidity transValidity; boolean testTrans = true; while (this.firstNotCacheableTransformerIndex < transformerSize && testTrans) { trans = (Transformer)this.transformers.get(this.firstNotCacheableTransformerIndex); if (trans instanceof Cacheable) { transKey = ((Cacheable)trans).generateKey(); transValidity = ((Cacheable)trans).generateValidity(); if (transKey != 0 && transValidity != null) { transCacheKey = new ComponentCacheKey( ComponentCacheKey.ComponentType_Transformer, (String)this.transformerRoles.get(this.firstNotCacheableTransformerIndex), transKey); this.pipelineCacheKey.addKey(transCacheKey); this.validityObjects.put(transCacheKey, transValidity); } else { testTrans = false; } } else { testTrans = false; } if (testTrans) { this.firstNotCacheableTransformerIndex++; } } // all transformers are cacheable => pipeline is cacheable if (this.firstNotCacheableTransformerIndex == transformerSize) { this.cacheable = true; } } } this.setupFinished = true; } */ /** Connect the pipeline. private void connectPipeline(Environment environment, ArrayList usedTransformers, XMLSerializer xmlSerializer) throws ProcessingException { XMLProducer prev = this.producer; XMLConsumer next; boolean configuredSAXConnector = this.manager.hasComponent(SAXConnector.ROLE); try { int cacheableTransformerCount = this.firstNotCacheableTransformerIndex; Iterator itt = usedTransformers.iterator(); while ( itt.hasNext() ) { if (configuredSAXConnector) { // connect SAXConnector SAXConnector connect = (SAXConnector) this.manager.lookup(SAXConnector.ROLE); connect.setup(environment,environment.getObjectModel(),null,null); this.connectors.add(connect); next = connect; prev.setConsumer(next); prev = connect; } // Connect next component. next = (XMLConsumer) itt.next(); if (xmlSerializer != null) { if (cacheableTransformerCount == 0) { next = new XMLTeePipe(next, xmlSerializer); xmlSerializer = null; } else { cacheableTransformerCount--; } } prev.setConsumer(next); prev = (XMLProducer) next; } if (configuredSAXConnector) { // insert SAXConnector SAXConnector connect = (SAXConnector) this.manager.lookup(SAXConnector.ROLE); connect.setup(environment,environment.getObjectModel(),null,null); this.connectors.add(connect); next = connect; prev.setConsumer(next); prev = connect; } // insert this consumer next = super.xmlConsumer; if (xmlSerializer != null) { next = new XMLTeePipe(next, xmlSerializer); xmlSerializer = null; } prev.setConsumer(next); } catch ( IOException e ) { throw new ProcessingException( "Could not connect pipeline.", e ); } catch ( SAXException e ) { throw new ProcessingException( "Could not connect pipeline.", e ); } catch ( ComponentException e ) { throw new ProcessingException( "Could not connect pipeline.", e ); } } */ /** Process the pipeline using a reader. * @throws ProcessingException if protected boolean processReader(Environment environment) throws ProcessingException { try { this.reader.setup(environment,environment.getObjectModel(),readerSource,readerParam); String mimeType = this.reader.getMimeType(); mimeType = this.reader.getMimeType(); if ( mimeType != null ) { environment.setContentType(mimeType); } else if ( readerMimeType != null ) { environment.setContentType(this.readerMimeType); } else { environment.setContentType(this.sitemapReaderMimeType); } // has the read resource been modified? long lastModified = this.reader.getLastModified(); if (lastModified != 0 && !environment.isResponseModified(lastModified)) { // environment supports this, so we are finished environment.setResponseIsNotModified(); return true; } } catch (SAXException e){ getLogger().debug("SAXException in ProcessReader", e); throw new ProcessingException( "Failed to execute pipeline.", e ); } catch (IOException e){ getLogger().debug("IOException in ProcessReader", e); throw new ProcessingException( "Failed to execute pipeline.", e ); } try { boolean usedCache = false; OutputStream outputStream; PipelineCacheKey pcKey = null; Map validityObjects = new HashMap(); outputStream = environment.getOutputStream(); // test if serializer and event pipeline are cacheable long readerKey = 0; CacheValidity readerValidity = null; if (this.reader instanceof Cacheable && (readerKey = ((Cacheable)this.reader).generateKey()) != 0 && (readerValidity = ((Cacheable)this.reader).generateValidity()) != null ){ // response is cacheable, build the key ComponentCacheKey ccKey; pcKey = new PipelineCacheKey(); ccKey = new ComponentCacheKey(ComponentCacheKey.ComponentType_Reader, this.readerRole, readerKey); validityObjects.put(ccKey, readerValidity); pcKey.addKey(ccKey); // now we have the key to get the cached object CachedStreamObject cachedObject = (CachedStreamObject)this.streamCache.get(pcKey); if (cachedObject != null) { getLogger().debug("Found cached response for '" + environment.getURI() + "'."); Iterator validityIterator = validityObjects.keySet().iterator(); ComponentCacheKey validityKey; boolean valid = true; while (validityIterator.hasNext() && valid) { validityKey = (ComponentCacheKey)validityIterator.next(); valid = cachedObject.isValid(validityKey, (CacheValidity)validityObjects.get(validityKey)); if (getLogger().isDebugEnabled()) { CacheValidity cachedValidity = cachedObject.getCacheValidity(validityKey); getLogger().debug("Compared cached validity '" + cachedValidity + "' with new validity '" + validityObjects.get(validityKey) + "' : " + (valid ? "valid" : "changed")); } } if (valid) { getLogger().debug("Using valid cached content for '" + environment.getURI() + "'."); byte[] response = cachedObject.getResponse(); if(response.length > 0) { usedCache = true; environment.setContentLength(response.length); outputStream.write(response); } } if(!usedCache) { getLogger().debug("Cached content is invalid for '" + environment.getURI() + "'."); // remove invalid cached object this.streamCache.remove(pcKey); cachedObject = null; } } if (cachedObject == null) { getLogger().debug("Caching content for further requests of '" + environment.getURI() + "'."); outputStream = new CachingOutputStream(outputStream); } } if (!usedCache) { if (this.reader.shouldSetContentLength()) { ByteArrayOutputStream os = new ByteArrayOutputStream(); this.reader.setOutputStream(os); this.reader.generate(); byte[] data = os.toByteArray(); environment.setContentLength(data.length); outputStream.write(data); } else { this.reader.setOutputStream(outputStream); this.reader.generate(); } // store the response if (pcKey != null) { this.streamCache.store(pcKey, new CachedStreamObject(validityObjects, ((CachingOutputStream)outputStream).getContent())); } } } catch ( SocketException se ) { if (se.getMessage().indexOf("reset") > 0 || se.getMessage().indexOf("aborted") > 0) { throw new ConnectionResetException("Connection reset by peer", se); } else { getLogger().debug("SocketException in ProcessReader", se); throw new ProcessingException( "Failed to execute pipeline.", se ); } } catch ( ProcessingException e ) { throw e; } catch ( Exception e ) { getLogger().debug("Exception in ProcessReader", e); throw new ProcessingException( "Failed to execute pipeline.", e ); } return true; } */ /** * Process the request. public boolean process(Environment environment) throws ProcessingException { if ( super.reader != null ) { return super.process(environment); } else { if ( !this.checkPipeline() ) { throw new ProcessingException("Attempted to process incomplete pipeline."); } try { boolean usedCache = false; OutputStream outputStream; PipelineCacheKey pcKey = null; Map validityObjects = null; outputStream = environment.getOutputStream(); this.setupPipeline(environment); this.connectPipeline(); // test if serializer and event pipeline are cacheable long serializerKey = 0; PipelineCacheKey eventPipelineKey = null; CacheValidity serializerValidity = null; Map eventPipelineValidity = null; if (this.eventPipeline instanceof CacheableEventPipeline) { if (this.serializer instanceof Cacheable && (serializerKey = ((Cacheable)this.serializer).generateKey()) != 0 && (serializerValidity = ((Cacheable)this.serializer).generateValidity()) != null && (eventPipelineKey = ((CacheableEventPipeline)this.eventPipeline).generateKey(environment)) != null && (eventPipelineValidity = ((CacheableEventPipeline)this.eventPipeline).generateValidity(environment)) != null) { // tell the event pipeline that it must not cache ((CacheableEventPipeline)this.eventPipeline).setStreamPipelineCaches(true); // response is cacheable, build the key validityObjects = eventPipelineValidity; ComponentCacheKey ccKey; pcKey = new PipelineCacheKey(); ccKey = new ComponentCacheKey(ComponentCacheKey.ComponentType_Serializer, this.serializerRole, serializerKey); validityObjects.put(ccKey, serializerValidity); pcKey.addKey(ccKey); pcKey.addKey(eventPipelineKey); // now we have the key to get the cached object CachedStreamObject cachedObject = (CachedStreamObject)this.streamCache.get(pcKey); if (cachedObject != null) { getLogger().debug("Found cached response for '" + environment.getURI() + "'."); Iterator validityIterator = validityObjects.keySet().iterator(); ComponentCacheKey validityKey; boolean valid = true; while (validityIterator.hasNext() && valid) { validityKey = (ComponentCacheKey)validityIterator.next(); valid = cachedObject.isValid(validityKey, (CacheValidity)validityObjects.get(validityKey)); if (getLogger().isDebugEnabled()) { CacheValidity cachedValidity = cachedObject.getCacheValidity(validityKey); getLogger().debug("Compared cached validity '" + cachedValidity + "' with new validity '" + validityObjects.get(validityKey) + "' : " + (valid ? "valid" : "changed")); } } if (valid) { getLogger().debug("Using valid cached content for '" + environment.getURI() + "'."); byte[] bytes = cachedObject.getResponse(); if(bytes.length > 0) { usedCache = true; environment.setContentLength(bytes.length); outputStream.write(bytes); } } if (!usedCache) { getLogger().debug("Cached content is invalid for '" + environment.getURI() + "'."); // remove invalid cached object this.streamCache.remove(pcKey); cachedObject = null; } } if (cachedObject == null) { getLogger().debug("Caching content for further requests of '" + environment.getURI() + "'."); outputStream = new CachingOutputStream(outputStream); } } else { ((CacheableEventPipeline)this.eventPipeline).setStreamPipelineCaches(false); } } if (!usedCache) { if (this.serializer.shouldSetContentLength()) { // set the output stream ByteArrayOutputStream os = new ByteArrayOutputStream(); this.serializer.setOutputStream(os); // execute the pipeline: this.eventPipeline.process(environment); byte[] data = os.toByteArray(); environment.setContentLength(data.length); outputStream.write(data); } else { // set the output stream this.serializer.setOutputStream(outputStream); // execute the pipeline: this.eventPipeline.process(environment); } // store the response if (pcKey != null) { byte[] bytes = ((CachingOutputStream)outputStream).getContent(); this.streamCache.store(pcKey, new CachedStreamObject(validityObjects, bytes)); } } } catch ( ProcessingException e ) { throw e; } catch ( Exception e ) { getLogger().debug("Exception in process", e); throw new ProcessingException( "Failed to execute pipeline.", e ); } return true; } } */ /** * Recyclable Interface */ public void recycle() { super.recycle(); this.generatorRole = null; this.transformerRoles.clear(); this.serializerRole = null; this.readerRole = null; this.notCacheableTransformers.clear(); this.validityObjects = null; this.pipelineCacheKey = null; this.setupFinished = false; this.cacheable = false; } /** * Disposable Interface */ public void dispose() { this.manager.release(this.cache); } } 1.1 xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/NonCachingProcessingPipeline.java Index: NonCachingProcessingPipeline.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi . For more information on the Apache Software Foundation, please see . */ package org.apache.cocoon.components.pipeline; /** * @author Giacomo Pati * @version CVS $Id: NonCachingProcessingPipeline.java,v 1.1 2002/05/02 14:20:46 cziegeler Exp $ */ public class NonCachingProcessingPipeline extends AbstractProcessingPipeline { } ---------------------------------------------------------------------- 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