cziegeler    02/05/28 04:33:58

  Modified:    src/java/org/apache/cocoon/components/pipeline/impl
                        CachingProcessingPipeline.java
  Log:
  Fixing bugs - caching of complete pipelines works now
  
  Revision  Changes    Path
  1.19      +16 -16    
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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- CachingProcessingPipeline.java    28 May 2002 10:51:31 -0000      1.18
  +++ CachingProcessingPipeline.java    28 May 2002 11:33:57 -0000      1.19
  @@ -92,7 +92,7 @@
    *
    * @since @next-version@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Id: CachingProcessingPipeline.java,v 1.18 2002/05/28 10:51:31 
cziegeler Exp $
  + * @version CVS $Id: CachingProcessingPipeline.java,v 1.19 2002/05/28 11:33:57 
cziegeler Exp $
    */
   public class CachingProcessingPipeline
   extends AbstractProcessingPipeline
  @@ -115,8 +115,6 @@
   
       /** The deserializer */
       protected XMLDeserializer xmlDeserializer;
  -    /** Complete response is cached */
  -    protected boolean completeResponseIsCached;
       /** The serializer */
       protected XMLSerializer xmlSerializer;
   
  @@ -124,6 +122,8 @@
       protected byte[]           cachedResponse;
       /** The index indicating the first transformer getting input from the cache */
       protected int firstProcessedTransformerIndex;
  +    /** Complete response is cached */
  +    protected boolean completeResponseIsCached;
   
       /** The key to store the generated response */
       protected PipelineCacheKey   pipelineCacheKey;
  @@ -131,7 +131,8 @@
       protected SourceValidity[]   pipelineValidityObjects;
       /** The index indicating to the first transformer which is not cacheable */
       protected int firstNotCacheableTransformerIndex;
  -
  +    /** Cache complete response */
  +    protected boolean cacheCompleteResponse;
   
       /**
        * Composable Interface
  @@ -208,11 +209,10 @@
   
               if (this.getLogger().isDebugEnabled()) {
                   this.getLogger().debug("Caching content for further requests of '" 
+ environment.getURI() + "'.");
  -                System.out.println("Caching content for further requests of '" + 
environment.getURI() + "'.");
               }
               try {
                   OutputStream os = environment.getOutputStream();
  -                if ( this.completeResponseIsCached ) {
  +                if ( this.cacheCompleteResponse ) {
                        os = new CachingOutputStream( os );
                   }
                   if (this.serializer.shouldSetContentLength()) {
  @@ -239,14 +239,14 @@
                           this.generator.generate();
                       }
                   }
  -                if ( this.completeResponseIsCached ) {
  +                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,
  +                     CachedResponse response = new 
CachedResponse(this.pipelineValidityObjects,
                                        (byte[])this.xmlSerializer.getSAXFragment());
                        this.cache.store(environment.getObjectModel(),
                                            this.pipelineCacheKey,
  @@ -289,8 +289,8 @@
           this.firstNotCacheableTransformerIndex = 0;
           this.firstProcessedTransformerIndex = 0;
           this.completeResponseIsCached = false;
  +        this.cacheCompleteResponse = false;
   
  -        System.out.println("Generating key.");
           // first step is to generate the key:
           // All pipeline components starting with the generator
           // are tested if they are either a CacheableProcessingComponent
  @@ -354,11 +354,11 @@
                                                                           key)
                                                    );
                       this.completeResponseIsCached = true;
  +                    this.cacheCompleteResponse = true;
                   }
               }
           }
   
  -        System.out.println("Generated key:"+processingPipelineKey);
           // now, we have a key representing all cacheable components up to the
           // first non cacheable
           if (processingPipelineKey != null) {
  @@ -377,7 +377,6 @@
                   boolean responseIsUsable = true;
                   if (this.getLogger().isDebugEnabled()) {
                       this.getLogger().debug("Found cached response for '" + 
environment.getURI() + "'.");
  -                   System.out.println("Found cached response for '" + 
environment.getURI() + "'.");
                   }
                   this.cachedResponse = response.getResponse();
                   SourceValidity[] validities = response.getValidityObjects();
  @@ -428,12 +427,10 @@
                       cachedValidityObjects = validities;
                       if (this.getLogger().isDebugEnabled()) {
                           this.getLogger().debug("Using valid cached content for '" + 
environment.getURI() + "'.");
  -                        System.out.println("Using valid cached content for '" + 
environment.getURI() + "'.");
                       }
                   } else {
                       if (this.getLogger().isDebugEnabled()) {
                           this.getLogger().debug("Cached content is invalid for '" + 
environment.getURI() + "'.");
  -                        System.out.println("Cached content is invalid for '" + 
environment.getURI() + "'.");
                       }
                       // we are not valid!
                       this.completeResponseIsCached = false;
  @@ -455,6 +452,7 @@
                           } else {
                               processingPipelineKey = null;
                           }
  +                        this.cacheCompleteResponse = false;
                       } else {
                           // the entry is invalid, remove it
                           this.cache.remove( cachedPipelineKey );
  @@ -470,7 +468,6 @@
               } else {
                   if (this.getLogger().isDebugEnabled()) {
                       this.getLogger().debug("Cached response not found for '" + 
environment.getURI() + "'.");
  -                    System.out.println("Cached response not found for '" + 
environment.getURI() + "'.");
                   }
                   finished = false;
                   this.completeResponseIsCached = false;
  @@ -542,8 +539,11 @@
               return;
           } else {
               try {
  -                this.xmlSerializer = (XMLSerializer)this.manager.lookup( 
XMLSerializer.ROLE );
  -                XMLSerializer localXMLSerializer = this.xmlSerializer;
  +                XMLSerializer localXMLSerializer = null;
  +                if (!this.cacheCompleteResponse) {
  +                    this.xmlSerializer = (XMLSerializer)this.manager.lookup( 
XMLSerializer.ROLE );
  +                    localXMLSerializer = this.xmlSerializer;
  +                }
                   if ( this.cachedResponse == null ) {
                       XMLProducer prev = super.generator;
                       XMLConsumer next;
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to