cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl CachingProcessingPipeline.java
Date Mon, 06 May 2002 14:17:54 GMT
cziegeler    02/05/06 07:17:54

  Modified:    src/java/org/apache/cocoon/caching
                        CacheValidityToSourceValidity.java
               src/java/org/apache/cocoon/components/pipeline
                        AbstractProcessingPipeline.java
               src/java/org/apache/cocoon/components/pipeline/impl
                        CachingProcessingPipeline.java
  Log:
  Minor update of the new caching pipeline
  
  Revision  Changes    Path
  1.2       +2 -1      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CacheValidityToSourceValidity.java	6 May 2002 13:22:31 -0000	1.1
  +++ CacheValidityToSourceValidity.java	6 May 2002 14:17:53 -0000	1.2
  @@ -56,8 +56,9 @@
    * A CacheValidity object wrapping the Avalon Excalibur
    * <code>SourceValidity</code> object.
    *
  + * @since @next-version@
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Id: CacheValidityToSourceValidity.java,v 1.1 2002/05/06 13:22:31 cziegeler
Exp $
  + * @version CVS $Id: CacheValidityToSourceValidity.java,v 1.2 2002/05/06 14:17:53 cziegeler
Exp $
    */
   public final class CacheValidityToSourceValidity
   implements SourceValidity {
  
  
  
  1.7       +2 -2      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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractProcessingPipeline.java	3 May 2002 14:47:33 -0000	1.6
  +++ AbstractProcessingPipeline.java	6 May 2002 14:17:54 -0000	1.7
  @@ -79,8 +79,9 @@
   /**
    * This is the base for all implementations of a <code>ProcessingPipeline</code>.
    *
  + * @since @next-version@
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Id: AbstractProcessingPipeline.java,v 1.6 2002/05/03 14:47:33 cziegeler
Exp $
  + * @version CVS $Id: AbstractProcessingPipeline.java,v 1.7 2002/05/06 14:17:54 cziegeler
Exp $
    */
   public abstract class AbstractProcessingPipeline
     extends AbstractLogEnabled
  @@ -343,7 +344,6 @@
                   // No mimeType available
                   String message = "Unable to determine MIME type for " +
                       environment.getURIPrefix() + "/" + environment.getURI();
  -                getLogger().error(message);
                   throw new ProcessingException(message);
               }
           } catch (SAXException e) {
  
  
  
  1.6       +80 -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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CachingProcessingPipeline.java	6 May 2002 13:22:31 -0000	1.5
  +++ CachingProcessingPipeline.java	6 May 2002 14:17:54 -0000	1.6
  @@ -61,6 +61,7 @@
   import org.apache.cocoon.caching.Cacheable;
   import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.caching.CachedResponse;
  +import org.apache.cocoon.caching.CacheValidity;
   import org.apache.cocoon.caching.CacheValidityToSourceValidity;
   import org.apache.cocoon.caching.CachingOutputStream;
   import org.apache.cocoon.components.pipeline.AbstractProcessingPipeline;
  @@ -86,9 +87,9 @@
   /**
    * The CachingProcessingPipeline
    *
  - *
  + * @since @next-version@
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Id: CachingProcessingPipeline.java,v 1.5 2002/05/06 13:22:31 cziegeler
Exp $
  + * @version CVS $Id: CachingProcessingPipeline.java,v 1.6 2002/05/06 14:17:54 cziegeler
Exp $
    */
   public class CachingProcessingPipeline
   extends AbstractProcessingPipeline
  @@ -284,13 +285,13 @@
                                    .append(key);
   
               // now testing transformers
  -            Transformer trans;
               final int transformerSize = this.transformers.size();
  -            boolean testTrans = true;
  +            boolean continueTest = true;
   
               while (this.firstNotCacheableTransformerIndex < transformerSize
  -                   && testTrans) {
  -                trans = (Transformer)this.transformers.get(this.firstNotCacheableTransformerIndex);
  +                   && continueTest) {
  +                final Transformer trans =
  +                    (Transformer)this.transformers.get(this.firstNotCacheableTransformerIndex);
                   key = 0;
                   if (trans instanceof CacheableProcessingComponent) {
                       key = ((CacheableProcessingComponent)trans).generateKey();
  @@ -304,10 +305,10 @@
                                            .append(key);
                       this.firstNotCacheableTransformerIndex++;
                   } else {
  -                    testTrans = false;
  +                    continueTest = false;
                   }
               }
  -            // all transformers are cacheable => pipeline is cacheable
  +            // all transformers are cacheable => pipeline is cacheable, test serializer
               if (this.firstNotCacheableTransformerIndex == transformerSize
                   && this.serializer == this.lastConsumer) {
   
  @@ -325,6 +326,61 @@
                   }
               }
           }
  +
  +        // now, if we have a key, let's see if there is a cached response
  +        if (this.pipelineCacheKey != null) {
  +            CachedResponse response = this.cache.get(this.pipelineCacheKey.toString());
  +            // now test validity
  +            if (response != null) {
  +                boolean isValid = true;
  +                SourceValidity[] validities = response.getValidityObjects();
  +                int i = 0;
  +                while (i < validities.length && isValid) {
  +                    isValid = validities[i].isValid();
  +                    if ( !isValid ) {
  +                        final SourceValidity validity;
  +                        if (i == 0) {
  +                            // test generator
  +                            if (this.generator instanceof Cacheable) {
  +                                validity = new CacheValidityToSourceValidity(((Cacheable)this.generator).generateValidity());
  +                            } else {
  +                                validity = ((CacheableProcessingComponent)this.generator).generateValidity();
  +                            }
  +                        } else if (i >= firstNotCacheableTransformerIndex + 1) {
  +                            // test transformer
  +                            // FIXME
  +                            validity = null;
  +                        } else {
  +                            // test serializer
  +                            // FIXME
  +                            validity = null;
  +                        }
  +                        if (validity != null) {
  +                            isValid = validities[i].isValid( validity );
  +                        }
  +                        if ( !isValid ) {
  +                            // update validity
  +                            validities[i] = validity;
  +                        }
  +                    }
  +                    if ( isValid ) i++;
  +                }
  +                // FIXME
  +                if ( isValid ) {
  +                    // we are valid, ok that's it
  +                } else {
  +                    // we are not valid!
  +                    if (validities[i] == null) {
  +                        // we can try a shorter key now...
  +                        // but we don't invalidate the current entry!
  +                    } else {
  +                        // invalidate entry
  +                        this.cache.remove(this.pipelineCacheKey.toString());
  +                        // let's get the rest of the validities now
  +                    }
  +                }
  +            }
  +        }
       }
   
       /** Connect the pipeline.
  @@ -450,11 +506,14 @@
                           if (isCacheableProcessingComponent) {
                               readerValidity = ((CacheableProcessingComponent)this.reader).generateValidity();
                           } else {
  -                            readerValidity = new CacheValidityToSourceValidity(
  -                                  ((Cacheable)this.reader).generateValidity()
  -                                );
  +                            CacheValidity cv = ((Cacheable)this.reader).generateValidity();
  +                            if ( cv != null ) {
  +                                readerValidity = new CacheValidityToSourceValidity( cv
);
  +                            }
  +                        }
  +                        if (readerValidity != null) {
  +                             valid = cachedValidity.isValid(readerValidity);
                           }
  -                        valid = cachedValidity.isValid(readerValidity);
                       }
   
                       if (valid) {
  @@ -487,12 +546,17 @@
                           if (isCacheableProcessingComponent) {
                               readerValidity = ((CacheableProcessingComponent)this.reader).generateValidity();
                           } else {
  -                            readerValidity = new CacheValidityToSourceValidity(
  -                                  ((Cacheable)this.reader).generateValidity()
  -                                );
  +                            CacheValidity cv = ((Cacheable)this.reader).generateValidity();
  +                            if ( cv != null ) {
  +                                readerValidity = new CacheValidityToSourceValidity( cv
);
  +                            }
                           }
                       }
  -                    outputStream = new CachingOutputStream(outputStream);
  +                    if (readerValidity != null) {
  +                        outputStream = new CachingOutputStream(outputStream);
  +                    } else {
  +                        pcKey = null;
  +                    }
                   }
   
                   super.processReader( environment, outputStream );
  
  
  

----------------------------------------------------------------------
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


Mime
View raw message