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/source/impl SourceDeferredValidity.java
Date Mon, 13 Jan 2003 13:12:30 GMT
cziegeler    2003/01/13 05:12:30

  Modified:    src/blocks/chaperon/java/org/apache/cocoon/transformation
                        TextFragmentParserTransformer.java
               src/java/org/apache/cocoon/components/pipeline/impl
                        AbstractCachingProcessingPipeline.java
                        CachingPointProcessingPipeline.java
                        CachingProcessingPipeline.java
               src/java/org/apache/cocoon/caching
                        CacheValidityToSourceValidity.java
                        SourceCacheValidity.java
               src/java/org/apache/cocoon/components/pipeline
                        ProcessingPipeline.java
                        AbstractProcessingPipeline.java
               src/blocks/chaperon/java/org/apache/cocoon/generation
                        TextParserGenerator.java
               src/java/org/apache/cocoon/components/modules/input
                        XMLFileModule.java
               lib/core excalibur-sourceresolve-20030109.jar
               src/java/org/apache/cocoon/components/source/impl
                        SourceDeferredValidity.java
  Added:       src/java/org/apache/cocoon/components/pipeline/impl
                        SourceDeferredValidity.java
  Removed:     src/java/org/apache/cocoon/components/pipeline/impl
                        NewAbstractCachingProcessingPipeline.java
  Log:
  Updating to latest excalibur - start new caching logic for deferred source validities
  
  Revision  Changes    Path
  1.3       +2 -2      xml-cocoon2/src/blocks/chaperon/java/org/apache/cocoon/transformation/TextFragmentParserTransformer.java
  
  Index: TextFragmentParserTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/blocks/chaperon/java/org/apache/cocoon/transformation/TextFragmentParserTransformer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TextFragmentParserTransformer.java	7 Jan 2003 23:56:08 -0000	1.2
  +++ TextFragmentParserTransformer.java	13 Jan 2003 13:12:29 -0000	1.3
  @@ -156,7 +156,7 @@
               // If the parser table has changed, rebuild the parser table
               if ((entry==null) ||
                   (entry.getValidity()==null) ||
  -                (!entry.getValidity().isValid(this.grammarSource.getValidity()))) {
  +                (entry.getValidity().isValid(this.grammarSource.getValidity()) != 1)) {
                   getLogger().debug("(Re)building the parsertable from '"+this.grammarSource.getSystemId()+"'");
   
                   SAXGrammarGenerator grammargenerator = new SAXGrammarGenerator();
  
  
  
  1.16      +203 -158  xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
  
  Index: AbstractCachingProcessingPipeline.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- AbstractCachingProcessingPipeline.java	9 Jan 2003 10:33:01 -0000	1.15
  +++ AbstractCachingProcessingPipeline.java	13 Jan 2003 13:12:29 -0000	1.16
  @@ -83,6 +83,7 @@
               extends AbstractProcessingPipeline
       implements Disposable {
   
  +    /** This is the Cache holding cached responses */
       protected Cache  cache;
   
       /** The role name of the generator */
  @@ -109,17 +110,28 @@
       /** Complete response is cached */
       protected boolean completeResponseIsCached;
   
  -    /** The key to store the generated response */
  -    protected PipelineCacheKey   pipelineCacheKey;
  -    /** The validity objects of the generated response */
  -    protected SourceValidity[]   pipelineValidityObjects;
  +
  +    /** This key indicates the response that is fetched from the cache */
  +    protected PipelineCacheKey fromCacheKey;
  +    /** This key indicates the response that will get into the cache */
  +    protected PipelineCacheKey toCacheKey;
  +    /** The source validities used for caching */
  +    protected SourceValidity[] toCacheSourceValidities;
  +    
       /** The index indicating to the first transformer which is not cacheable */
       protected int firstNotCacheableTransformerIndex;
       /** Cache complete response */
       protected boolean cacheCompleteResponse;
  +
  +    protected boolean   generatorIsCacheableProcessingComponent;
  +    protected boolean   serializerIsCacheableProcessingComponent;
  +    protected boolean[] transformerIsCacheableProcessingComponent;
  +
       /** Smart caching ? */
       protected boolean doSmartCaching;
  -
  +    /** Default setting for smart caching */
  +    protected boolean configuredDoSmartCaching;
  +    
       /**
        * Abstract methods defined in subclasses
        */
  @@ -137,12 +149,20 @@
       }
   
       /**
  +     * Parameterizable Interface - Configuration
  +     */
  +    public void parameterize(Parameters params) {
  +        super.parameterize(params);
  +        this.configuredDoSmartCaching = params.getParameterAsBoolean("smart-caching", true);
  +    }
  +    
  +    /**
        * Setup this component
        */
       public void setup(Parameters params) {
           super.setup(params);
           this.doSmartCaching = params.getParameterAsBoolean("smart-caching",
  -                              this.configuration.getParameterAsBoolean("smart-caching", true));
  +                                                           this.configuredDoSmartCaching);
       }
   
       /**
  @@ -187,7 +207,7 @@
        */
       protected boolean processXMLPipeline(Environment environment)
       throws ProcessingException {
  -        if (this.pipelineCacheKey == null && this.cachedResponse == null) {
  +        if (this.toCacheKey == null && this.cachedResponse == null) {
               return super.processXMLPipeline( environment );
           } else if (this.cachedResponse != null && this.completeResponseIsCached) {
               try {
  @@ -210,13 +230,13 @@
               }
           } else {
   
  -            if (this.getLogger().isDebugEnabled() && this.pipelineCacheKey != null) {
  -                this.getLogger().debug("Caching content for further requests of '" + environment.getURI() + "' using key " + this.pipelineCacheKey);
  +            if (this.getLogger().isDebugEnabled() && this.toCacheKey != null) {
  +                this.getLogger().debug("Caching content for further requests of '" + environment.getURI() + "' using key " + this.toCacheKey);
               }
               try {
                   OutputStream os = null;
                   
  -                if ( this.cacheCompleteResponse && this.pipelineCacheKey != null) {
  +                if ( this.cacheCompleteResponse && this.toCacheKey != null) {
                       os = new CachingOutputStream( environment.getOutputStream(this.outputBufferSize) );
                   }
                   if ( super.serializer != super.lastConsumer ) {
  @@ -285,25 +305,19 @@
       }
   
       /**
  -     * Setup the evenet pipeline.
  -     * The components of the pipeline are checked if they are
  -     * Cacheable.
  +     * The components of the pipeline are checked if they are Cacheable.
        */
  -    protected void setupPipeline(Environment environment)
  +    protected void generateCachingKey(Environment environment)
       throws ProcessingException {
  -        super.setupPipeline( environment );
   
  -        PipelineCacheKey cachedPipelineKey = null;
  -        PipelineCacheKey processingPipelineKey = null;
  +        this.toCacheKey = null;
   
           Serializable key = null;
  -        boolean generatorIsCacheableProcessingComponent = false;
  -        boolean serializerIsCacheableProcessingComponent = false;
  -        boolean[] transformerIsCacheableProcessingComponent = new boolean[this.transformers.size()];
  +        this.generatorIsCacheableProcessingComponent = false;
  +        this.serializerIsCacheableProcessingComponent = false;
  +        this.transformerIsCacheableProcessingComponent = new boolean[this.transformers.size()];
   
           this.firstNotCacheableTransformerIndex = 0;
  -        this.firstProcessedTransformerIndex = 0;
  -        this.completeResponseIsCached = false;
           this.cacheCompleteResponse = false;
   
           // first step is to generate the key:
  @@ -315,17 +329,17 @@
           // is the generator cacheable?
           if (super.generator instanceof CacheableProcessingComponent) {
               key = ((CacheableProcessingComponent)super.generator).generateKey();
  -            generatorIsCacheableProcessingComponent = true;
  +            this.generatorIsCacheableProcessingComponent = true;
           } else if (super.generator instanceof Cacheable) {
               key = new Long(((Cacheable)super.generator).generateKey());
           }
   
           if (key != null) {
  -            processingPipelineKey = new PipelineCacheKey();
  -            processingPipelineKey.addKey(this.newComponentCacheKey(ComponentCacheKey.ComponentType_Generator,
  -                                         this.generatorRole,
  -                                         key)
  -                                        );
  +            this.toCacheKey = new PipelineCacheKey();
  +            this.toCacheKey.addKey(this.newComponentCacheKey(ComponentCacheKey.ComponentType_Generator,
  +                                       this.generatorRole,
  +                                       key)
  +                              );
   
               // now testing transformers
               final int transformerSize = super.transformers.size();
  @@ -338,12 +352,12 @@
                   key = null;
                   if (trans instanceof CacheableProcessingComponent) {
                       key = ((CacheableProcessingComponent)trans).generateKey();
  -                    transformerIsCacheableProcessingComponent[this.firstNotCacheableTransformerIndex] = true;
  +                    this.transformerIsCacheableProcessingComponent[this.firstNotCacheableTransformerIndex] = true;
                   } else if (trans instanceof Cacheable) {
                       key = new Long(((Cacheable)trans).generateKey());
                   }
                   if (key != null) {
  -                    processingPipelineKey.addKey(this.newComponentCacheKey(ComponentCacheKey.ComponentType_Transformer,
  +                    this.toCacheKey.addKey(this.newComponentCacheKey(ComponentCacheKey.ComponentType_Transformer,
                                                    (String)this.transformerRoles.get(this.firstNotCacheableTransformerIndex),
                                                    key));
   
  @@ -352,232 +366,221 @@
                       continueTest = false;
                   }
               }
  -            // all transformers are cacheable => pipeline is cacheable, test serializer
  +            // all transformers are cacheable => pipeline is cacheable 
  +            // test serializer if this is not an internal request
               if (this.firstNotCacheableTransformerIndex == transformerSize
  -                    && super.serializer == this.lastConsumer) {
  +                && super.serializer == this.lastConsumer) {
   
                   key = null;
                   if (super.serializer instanceof CacheableProcessingComponent) {
                       key = ((CacheableProcessingComponent)this.serializer).generateKey();
  -                    serializerIsCacheableProcessingComponent = true;
  +                    this.serializerIsCacheableProcessingComponent = true;
                   } else if (this.serializer instanceof Cacheable) {
                       key = new Long(((Cacheable)this.serializer).generateKey());
                   }
                   if (key != null) {
  -                    processingPipelineKey.addKey(this.newComponentCacheKey(ComponentCacheKey.ComponentType_Serializer,
  +                    this.toCacheKey.addKey(this.newComponentCacheKey(ComponentCacheKey.ComponentType_Serializer,
                                                    (String)this.serializerRole,
                                                    key)
                                                   );
  -                    this.completeResponseIsCached = true;
                       this.cacheCompleteResponse = true;
                   }
               }
           }
  +    }
   
  -        // now, we have a key representing all cacheable components up to the
  -        // first non cacheable
  -        if (processingPipelineKey != null) {
  -            cachedPipelineKey = processingPipelineKey.copy();
  -            this.firstProcessedTransformerIndex = this.firstNotCacheableTransformerIndex;
  -        }
  +    /**
  +     * Calculate the key that can be used to get something from the cache
  +     */
  +    protected void validatePipeline(Environment environment)
  +    throws ProcessingException {
  +        this.completeResponseIsCached = this.cacheCompleteResponse;
  +        this.fromCacheKey = this.toCacheKey.copy();        
  +        this.firstProcessedTransformerIndex = this.firstNotCacheableTransformerIndex;
   
           boolean finished = false;
  -        SourceValidity[] cachedValidityObjects = null;
  -        while (cachedPipelineKey != null && !finished) {
  +        
  +        while (this.fromCacheKey != null && !finished) {
  +            
               finished = true;
  -            CachedResponse response = this.cache.get( cachedPipelineKey );
  +            final CachedResponse response = this.cache.get( this.fromCacheKey );
   
               // now test validity
               if (response != null) {
  -                boolean responseIsValid = true;
  -                boolean responseIsUsable = true;
                   if (this.getLogger().isDebugEnabled()) {
                       this.getLogger().debug(
                           "Found cached response for '" + environment.getURI() + 
  -                        "' using key: " + cachedPipelineKey
  +                        "' using key: " + this.fromCacheKey
                       );
                   }
  -                this.cachedResponse = response.getResponse();
  -                SourceValidity[] validities = response.getValidityObjects();
  +
  +                boolean responseIsValid = true;
  +                boolean responseIsUsable = true;
  +                SourceValidity[] fromCacheValidityObjects = response.getValidityObjects();
  +
                   int i = 0;
  -                while (responseIsValid && i < validities.length) {
  +                while (responseIsValid && i < fromCacheValidityObjects.length) {
                       boolean isValid = false;
                       // BH check if validities[i] is null, may happen
                       // if exception was thrown due to malformed content
  -                    SourceValidity validity = validities[i];
  +                    SourceValidity validity = fromCacheValidityObjects[i];
                       int valid = validity != null ? validity.isValid() : -1;
  -                    if ( valid == 0) {
  -                        if (i == 0) {
  -                            // test generator
  -                            if (generatorIsCacheableProcessingComponent) {
  -                                validity = ((CacheableProcessingComponent)super.generator).generateValidity();
  -                            } else {
  -                                validity = CacheValidityToSourceValidity.createValidity(((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 = CacheValidityToSourceValidity.createValidity(((Cacheable)trans).generateValidity());
  -                            }
  -                        } else {
  -                            // test serializer
  -                            if (serializerIsCacheableProcessingComponent) {
  -                                validity = ((CacheableProcessingComponent)super.serializer).generateValidity();
  +                    if ( valid == 0) { // don't know if valid, make second test
  +                       
  +                        validity = this.getValidityForInternalPipeline(i);
  +
  +                        if (validity != null) {
  +                            valid = fromCacheValidityObjects[i].isValid( validity );
  +                            if (valid == 0) {
  +                                validity = null;
                               } else {
  -                                validity = CacheValidityToSourceValidity.createValidity(((Cacheable)super.serializer).generateValidity());
  +                                isValid = (valid == 1);
                               }
                           }
  -                        if (validity != null) {
  -                            isValid = validities[i].isValid( validity );
  -                        }
                       } else {
                           isValid = (valid == 1);
                       }
                       if ( !isValid ) {
                           responseIsValid = false;
                           // update validity
  -                        validities[i] = validity;
                           if (validity == null)
                               responseIsUsable = false;
  -                    } else {
  +                    } else {                        
                           i++;
                       }
                   }
                   if ( responseIsValid ) {
  -                    // we are valid, ok that's it
  -                    cachedValidityObjects = validities;
                       if (this.getLogger().isDebugEnabled()) {
                           this.getLogger().debug("Using valid cached content for '" + environment.getURI() + "'.");
                       }
  +                    // we are valid, ok that's it
  +                    this.cachedResponse = response.getResponse();
                   } else {
                       if (this.getLogger().isDebugEnabled()) {
                           this.getLogger().debug("Cached content is invalid for '" + environment.getURI() + "'.");
                       }
                       // we are not valid!
  +
  +                    // try a shorter key
  +                    if (i > 0) {
  +                        this.fromCacheKey.removeLastKey();
  +                        if (!this.completeResponseIsCached) {
  +                            this.firstProcessedTransformerIndex--;
  +                        }
  +                    } else {
  +                        this.fromCacheKey = null;
  +                    }
  +
                       this.completeResponseIsCached = false;
                       finished = false;
  -                    this.cachedResponse = null;
   
                       if (!responseIsUsable) {
  -                        // we could compare, because we got no
  +                        // we could not compare, because we got no
                           // validity object, so shorten pipeline key
                           if (i > 0) {
  -                            int deleteCount = validities.length - i;
  +                            int deleteCount = fromCacheValidityObjects.length - i;
                               if (i > 0 && i <= firstNotCacheableTransformerIndex + 1) {
                                   this.firstNotCacheableTransformerIndex = i-1;
                               }
                               for(int x=0; x < deleteCount; x++) {
  -                                processingPipelineKey.removeLastKey();
  +                                this.toCacheKey.removeLastKey();
                               }
                               finished = false;
                           } else {
  -                            processingPipelineKey = null;
  +                            this.toCacheKey = null;
                           }
                           this.cacheCompleteResponse = false;
                       } else {
                           // the entry is invalid, remove it
  -                        this.cache.remove( cachedPipelineKey );
  -                    }
  -                    // try a shorter key
  -                    if (i > 0) {
  -                        cachedPipelineKey.removeLastKey();
  -                        this.firstProcessedTransformerIndex--;
  -                    } else {
  -                        cachedPipelineKey = null;
  +                        this.cache.remove( this.fromCacheKey );
                       }
                   }
               } else {
  +                
  +                // no cached response found
                   if (this.getLogger().isDebugEnabled()) {
                       this.getLogger().debug(
                           "Cached response not found for '" + environment.getURI() + 
  -                        "' using key: " +  cachedPipelineKey
  +                        "' using key: " +  this.fromCacheKey
                       );
                   }
  +
                   if (!this.doSmartCaching) {
                       // try a shorter key
  -                    // FIXME (CZ) calculation of PPK
  -                    if (cachedPipelineKey.size() > 1) {
  -                        cachedPipelineKey.removeLastKey();
  +                    if (this.fromCacheKey.size() > 1) {
  +                        this.fromCacheKey.removeLastKey();
                           if (!this.completeResponseIsCached) {
                               this.firstProcessedTransformerIndex--;
                           }
  +                        finished = false;
                       } else {
  -                        cachedPipelineKey = null;
  +                        this.fromCacheKey = null;
                       }
  -                    finished = false;
  -                    this.completeResponseIsCached = false;
                   } else {
                       // stop on longest key for smart caching
  -                    finished = true;
  -                    this.completeResponseIsCached = false;
  -                    cachedPipelineKey = null;
  +                    this.fromCacheKey = null;
                   }
  +                this.completeResponseIsCached = false;
               }
           }
   
  +    }
  +
  +    /**
  +     * Setup the evenet pipeline.
  +     * The components of the pipeline are checked if they are
  +     * Cacheable.
  +     */
  +    protected void setupPipeline(Environment environment)
  +    throws ProcessingException {
  +        super.setupPipeline( environment );
  +
  +        // generate the key to fill the cache
  +        this.generateCachingKey(environment);
  +
  +        // test the cache for a valid response
  +        if (this.toCacheKey != null) {
  +            this.validatePipeline(environment);
  +        }
  +        
           // now generate validity objects for the new response
  -        if (processingPipelineKey != null) {
  -            if (cachedPipelineKey == null ||
  -                    cachedPipelineKey.size() < processingPipelineKey.size()) {
  -                this.pipelineCacheKey = processingPipelineKey;
  -                this.pipelineValidityObjects = new SourceValidity[processingPipelineKey.size()];
  -                int start = 0;
  -                if (cachedPipelineKey != null) {
  -                    start = cachedPipelineKey.size();
  -                    for(int i=0; i<start;i++) {
  -                        this.pipelineValidityObjects[i] = cachedValidityObjects[i];
  -                    }
  -                }
  -                int len = this.pipelineValidityObjects.length;
  -                int i = start;
  +        if (this.toCacheKey != null) {
  +            // only update validity objects if we cannot use
  +            // a cached response or when the cached response does
  +            // cache less than now is cacheable
  +            if (this.fromCacheKey == null 
  +                || this.fromCacheKey.size() < this.toCacheKey.size()) {
  +                
  +                this.toCacheSourceValidities = new SourceValidity[this.toCacheKey.size()];
  +                int len = this.toCacheSourceValidities.length;
  +                int i = 0;
                   while (i < len) {
  -                    final SourceValidity validity;
  -                    if (i == 0) {
  -                        // test generator
  -                        if (generatorIsCacheableProcessingComponent) {
  -                            validity = ((CacheableProcessingComponent)super.generator).generateValidity();
  -                        } else {
  -                            validity = CacheValidityToSourceValidity.createValidity(((Cacheable)super.generator).generateValidity());
  -                        }
  -                    } else if (i <= firstNotCacheableTransformerIndex) {
  -                        // 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());
  -                        }
  -                    } else {
  -                        // test serializer
  -                        if (serializerIsCacheableProcessingComponent) {
  -                            validity = ((CacheableProcessingComponent)super.serializer).generateValidity();
  -                        } else {
  -                            validity = CacheValidityToSourceValidity.createValidity(((Cacheable)super.serializer).generateValidity());
  -                        }
  -                    }
  +                    final SourceValidity validity = this.getValidityForInternalPipeline(i);
  +
                       if (validity == null) {
  -                        if (i > 0 && i > cachedPipelineKey.size()) {
  +                        if (i > 0 && i > this.fromCacheKey.size()) {
                               // shorten key
  -                            for(int m=i; m < this.pipelineValidityObjects.length; m++) {
  -                                this.pipelineCacheKey.removeLastKey();
  +                            for(int m=i; m < this.toCacheSourceValidities.length; m++) {
  +                                this.toCacheKey.removeLastKey();
  +                                if (!this.cacheCompleteResponse) {
  +                                    this.firstNotCacheableTransformerIndex--;
  +                                }
  +                                this.cacheCompleteResponse = false;
                               }
                               SourceValidity[] copy = new SourceValidity[i];
  -                            System.arraycopy(this.pipelineValidityObjects, 0,
  +                            System.arraycopy(this.toCacheSourceValidities, 0,
                                                copy, 0, copy.length);
  -                            this.pipelineValidityObjects = copy;
  -                            len = this.pipelineValidityObjects.length;
  +                            this.toCacheSourceValidities = copy;
  +                            len = this.toCacheSourceValidities.length;
                           } else {
  -                            this.pipelineCacheKey = null;
  -                            this.pipelineValidityObjects = null;
  +                            // caching is not possible!
  +                            this.toCacheKey = null;
  +                            this.toCacheSourceValidities = null;
  +                            this.cacheCompleteResponse = false;
                               len = 0;
                           }
                       } else {
  -                        this.pipelineValidityObjects[i] = validity;
  +                        this.toCacheSourceValidities[i] = validity;
                       }
                       i++;
                   }
  @@ -590,7 +593,7 @@
        */
       protected void connectPipeline(Environment   environment)
       throws ProcessingException {
  -        if ( this.pipelineCacheKey == null && this.cachedResponse == null) {
  +        if ( this.toCacheKey == null && this.cachedResponse == null) {
               super.connectPipeline( environment );
               return;
           } else if (this.completeResponseIsCached) {
  @@ -658,7 +661,12 @@
                               }
                           }
                           if (readerValidity != null) {
  -                            valid = cachedValidity.isValid(readerValidity);
  +                            result = cachedValidity.isValid(readerValidity);
  +                            if ( result == 0 ) {
  +                                readerValidity = null;
  +                            } else {
  +                                valid = (result == 1);
  +                            }
                           }
                       } else {
                           valid = (result > 0);
  @@ -764,12 +772,44 @@
       public SourceValidity[] getValiditiesForEventPipeline() {
           if (!this.completeResponseIsCached
                   && this.firstNotCacheableTransformerIndex == super.transformers.size()) {
  -            return this.pipelineValidityObjects;
  +            return this.toCacheSourceValidities;
           }
           return null;
       }
   
       /**
  +     * 
  +     * @see org.apache.cocoon.components.pipeline.ProcessingPipeline#getValidityForInternalPipeline(int)
  +     */
  +    protected SourceValidity getValidityForInternalPipeline(int index) {
  +        final SourceValidity validity;
  +        if (index == 0) {
  +            // test generator
  +            if (this.generatorIsCacheableProcessingComponent) {
  +                validity = ((CacheableProcessingComponent)super.generator).generateValidity();
  +            } else {
  +                validity = CacheValidityToSourceValidity.createValidity(((Cacheable)super.generator).generateValidity());
  +            }
  +        } else if (index <= firstNotCacheableTransformerIndex) {
  +            // test transformer
  +            final Transformer trans = (Transformer)super.transformers.get(index-1);
  +            if (this.transformerIsCacheableProcessingComponent[index-1]) {
  +                validity = ((CacheableProcessingComponent)trans).generateValidity();
  +            } else {
  +                validity = CacheValidityToSourceValidity.createValidity(((Cacheable)trans).generateValidity());
  +            }
  +        } else {
  +            // test serializer
  +            if (this.serializerIsCacheableProcessingComponent) {
  +                validity = ((CacheableProcessingComponent)super.serializer).generateValidity();
  +            } else {
  +                validity = CacheValidityToSourceValidity.createValidity(((Cacheable)super.serializer).generateValidity());
  +            }
  +        }
  +        return validity;
  +    }
  +    
  +    /**
        * Recyclable Interface
        */
       public void recycle() {
  @@ -786,16 +826,21 @@
           this.serializerRole = null;
           this.readerRole = null;
   
  -        this.pipelineCacheKey = null;
  -        this.pipelineValidityObjects = null;
  +        this.fromCacheKey = null;
           this.cachedResponse = null;
  +        
  +        this.transformerIsCacheableProcessingComponent = null;
  +        this.toCacheKey = null;
  +        this.toCacheSourceValidities = null;
       }
   
       /**
        * Disposable Interface
        */
       public void dispose() {
  -        this.manager.release(this.cache);
  +        if ( null != this.manager ) {
  +            this.manager.release(this.cache);
  +        }
           this.cache = null;
           this.manager = null;
       }
  
  
  
  1.8       +21 -21    xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java
  
  Index: CachingPointProcessingPipeline.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CachingPointProcessingPipeline.java	5 Dec 2002 10:04:39 -0000	1.7
  +++ CachingPointProcessingPipeline.java	13 Jan 2003 13:12:29 -0000	1.8
  @@ -209,22 +209,22 @@
        */
       protected void cacheResults(Environment environment, OutputStream os)  throws Exception {
   
  -        if (this.pipelineCacheKey != null) {
  +        if (this.toCacheKey != null) {
               if ( this.cacheCompleteResponse ) {
                   if (this.getLogger().isDebugEnabled()) {
                       this.getLogger().debug("Cached: caching complete response; pSisze"
  -                                           + this.pipelineCacheKey.size() + " Key " + this.pipelineCacheKey);
  +                                           + this.toCacheKey.size() + " Key " + this.toCacheKey);
                   }
  -                CachedResponse response = new CachedResponse(this.pipelineValidityObjects,
  +                CachedResponse response = new CachedResponse(this.toCacheSourceValidities,
                                             ((CachingOutputStream)os).getContent());
                   this.cache.store(environment.getObjectModel(),
  -                                 this.pipelineCacheKey.copy(),
  +                                 this.toCacheKey.copy(),
                                    response);
           //
           // Scan back along the pipelineCacheKey for
           // for any cachepoint(s)
           //
  -            this.pipelineCacheKey.removeUntilCachePoint();
  +            this.toCacheKey.removeUntilCachePoint();
   
           //
           // adjust the validities object
  @@ -232,44 +232,44 @@
           //
           // REVISIT: Is it enough to simply reduce the length of the validities array?
           //
  -                if (this.pipelineCacheKey.size()>0) {
  -                    SourceValidity[] copy = new SourceValidity[this.pipelineCacheKey.size()];
  -                    System.arraycopy(this.pipelineValidityObjects, 0,
  +                if (this.toCacheKey.size()>0) {
  +                    SourceValidity[] copy = new SourceValidity[this.toCacheKey.size()];
  +                    System.arraycopy(this.toCacheSourceValidities, 0,
                                        copy, 0, copy.length);
  -                    this.pipelineValidityObjects = copy;
  +                    this.toCacheSourceValidities = copy;
                   }
               }
   
  -            if (this.pipelineCacheKey.size()>0) {
  +            if (this.toCacheKey.size()>0) {
                   ListIterator itt = this.xmlSerializerArray.listIterator(this.xmlSerializerArray.size());
                   while (itt.hasPrevious()) {
                       XMLSerializer serializer = (XMLSerializer) itt.previous();
  -                    CachedResponse response = new CachedResponse(this.pipelineValidityObjects,
  +                    CachedResponse response = new CachedResponse(this.toCacheSourceValidities,
                                                 (byte[])serializer.getSAXFragment());
                       this.cache.store(environment.getObjectModel(),
  -                                     this.pipelineCacheKey.copy(),
  +                                     this.toCacheKey.copy(),
                                        response);
   
                       if (this.getLogger().isDebugEnabled()) {
                           this.getLogger().debug("Caching results for the following key: "
  -                            + this.pipelineCacheKey);
  +                            + this.toCacheKey);
                       }
   
  -            //
  +                    //
                       // Check for further cachepoints
  -            //
  -                    pipelineCacheKey.removeUntilCachePoint();
  -                    if (this.pipelineCacheKey.size()==0)
  +                    //
  +                    toCacheKey.removeUntilCachePoint();
  +                    if (this.toCacheKey.size()==0)
                           // no cachePoint found in key
                           break;
   
                       //
                       // re-calculate validities array
                       //
  -                    SourceValidity[] copy = new SourceValidity[this.pipelineCacheKey.size()];
  -                    System.arraycopy(this.pipelineValidityObjects, 0,
  +                    SourceValidity[] copy = new SourceValidity[this.toCacheKey.size()];
  +                    System.arraycopy(this.toCacheSourceValidities, 0,
                                        copy, 0, copy.length);
  -                    this.pipelineValidityObjects = copy;
  +                    this.toCacheSourceValidities = copy;
                   } //end serializer loop
   
               }
  
  
  
  1.31      +6 -6      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.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- CachingProcessingPipeline.java	5 Dec 2002 10:04:39 -0000	1.30
  +++ CachingProcessingPipeline.java	13 Jan 2003 13:12:29 -0000	1.31
  @@ -80,18 +80,18 @@
       * Cache longest cachable key
       */
       protected void cacheResults(Environment environment, OutputStream os)  throws Exception {
  -        if (this.pipelineCacheKey != null) {
  +        if (this.toCacheKey != null) {
               if ( this.cacheCompleteResponse ) {
  -                CachedResponse response = new CachedResponse(this.pipelineValidityObjects,
  +                CachedResponse response = new CachedResponse(this.toCacheSourceValidities,
                                             ((CachingOutputStream)os).getContent());
                   this.cache.store(environment.getObjectModel(),
  -                                 this.pipelineCacheKey,
  +                                 this.toCacheKey,
                                    response);
               } else {
  -                CachedResponse response = new CachedResponse(this.pipelineValidityObjects,
  +                CachedResponse response = new CachedResponse(this.toCacheSourceValidities,
                                             (byte[])this.xmlSerializer.getSAXFragment());
                   this.cache.store(environment.getObjectModel(),
  -                                 this.pipelineCacheKey,
  +                                 this.toCacheKey,
                                    response);
               }
           }
  
  
  
  1.1                  xml-cocoon2/src/java/org/apache/cocoon/components/pipeline/impl/SourceDeferredValidity.java
  
  Index: SourceDeferredValidity.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  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.components.pipeline.impl;
  
  import org.apache.cocoon.components.pipeline.ProcessingPipeline;
  import org.apache.excalibur.source.SourceValidity;
  import org.apache.excalibur.source.impl.validity.DeferredValidity;
  
  /**
   * Implementation of a {@link Source} that gets its content
   * by invoking a pipeline.
   *
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $Id: SourceDeferredValidity.java,v 1.1 2003/01/13 13:12:29 cziegeler Exp $
   */
  public final class SourceDeferredValidity implements DeferredValidity {
  
      private ProcessingPipeline pipeline;
      private int index;
      private SourceValidity[] validities;
      
      public SourceDeferredValidity(ProcessingPipeline pipeline, int index) {
          this.pipeline = pipeline;
          this.index = index;
      }
      
  	/**
  	 * @see org.apache.excalibur.source.impl.validity.DeferredValidity#getValidity()
  	 */
  	public SourceValidity getValidity() {
  		return this.validities[this.index];
  	}
  
  }
  
  
  
  1.7       +7 -4      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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CacheValidityToSourceValidity.java	4 Jul 2002 11:46:05 -0000	1.6
  +++ CacheValidityToSourceValidity.java	13 Jan 2003 13:12:29 -0000	1.7
  @@ -101,11 +101,14 @@
        * The invocation order is that the isValid method of the
        * old Validity object is called with the new one as a parameter
        */
  -    public boolean isValid( SourceValidity newValidity ) {
  +    public int isValid( SourceValidity newValidity ) {
           if (newValidity instanceof CacheValidityToSourceValidity) {
  -            return this.cacheValidity.isValid(((CacheValidityToSourceValidity)newValidity).cacheValidity);
  +            if (this.cacheValidity.isValid(((CacheValidityToSourceValidity)newValidity).cacheValidity)) {
  +                return 1;
  +            }
  +            return -1;
           }
  -        return false;
  +        return -1;
       }
   
       public String toString() {
  
  
  
  1.8       +5 -2      xml-cocoon2/src/java/org/apache/cocoon/caching/SourceCacheValidity.java
  
  Index: SourceCacheValidity.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/caching/SourceCacheValidity.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SourceCacheValidity.java	4 Jul 2002 11:46:05 -0000	1.7
  +++ SourceCacheValidity.java	13 Jan 2003 13:12:29 -0000	1.8
  @@ -81,7 +81,10 @@
           final int valid = this.sourceValidity.isValid();
           if (valid == 1) return true;
           if (valid == 0 && validity instanceof SourceCacheValidity) {
  -            return this.sourceValidity.isValid(((SourceCacheValidity)validity).getSourceValidity());
  +            if (this.sourceValidity.isValid(((SourceCacheValidity)validity).getSourceValidity()) == 1) {
  +                return true;
  +            }
  +            
           }
           return false;
       }
  
  
  
  1.15      +1 -4      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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ProcessingPipeline.java	10 Jan 2003 10:44:43 -0000	1.14
  +++ ProcessingPipeline.java	13 Jan 2003 13:12:29 -0000	1.15
  @@ -183,7 +183,4 @@
        */
       SourceValidity[] getValiditiesForEventPipeline();
   
  -    boolean isInternalPipelineCacheable();
  -    
  -    SourceValidity getValidityForInternalPipeline(int index);
   }
  
  
  
  1.29      +1 -9      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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- AbstractProcessingPipeline.java	10 Jan 2003 10:44:43 -0000	1.28
  +++ AbstractProcessingPipeline.java	13 Jan 2003 13:12:29 -0000	1.29
  @@ -756,12 +756,4 @@
           return System.currentTimeMillis() + expires;
       }
   
  -    public boolean isInternalPipelineCacheable() {
  -        return false;
  -    }
  -    
  -    public SourceValidity getValidityForInternalPipeline(int index) {
  -        return null;
  -    }
  -
   }
  
  
  
  1.3       +2 -2      xml-cocoon2/src/blocks/chaperon/java/org/apache/cocoon/generation/TextParserGenerator.java
  
  Index: TextParserGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/blocks/chaperon/java/org/apache/cocoon/generation/TextParserGenerator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TextParserGenerator.java	7 Jan 2003 23:56:08 -0000	1.2
  +++ TextParserGenerator.java	13 Jan 2003 13:12:29 -0000	1.3
  @@ -183,7 +183,7 @@
               // If the parser table has changed, rebuild the parser table
               if ((entry==null) ||
                   (entry.getValidity()==null) ||
  -                (!entry.getValidity().isValid(this.grammarSource.getValidity()))) {
  +                (entry.getValidity().isValid(this.grammarSource.getValidity()) != 1)) {
                   getLogger().debug("(Re)building the parsertable from '"+this.grammarSource.getSystemId()+"'");
   
                   SAXGrammarGenerator grammargenerator = new SAXGrammarGenerator();
  
  
  
  1.5       +2 -2      xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java
  
  Index: XMLFileModule.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XMLFileModule.java	22 Dec 2002 17:02:17 -0000	1.4
  +++ XMLFileModule.java	13 Jan 2003 13:12:30 -0000	1.5
  @@ -163,7 +163,7 @@
                           logger.debug("document cached... checking validity of uri "+this.uri);
                       src = resolver.resolveURI(this.uri);
                       valid = src.getValidity();
  -                    if (srcVal != null && !this.srcVal.isValid(valid)) {
  +                    if (srcVal != null && this.srcVal.isValid(valid) != 1) {
                           if (logger.isDebugEnabled())
                               logger.debug("reloading document... uri "+this.uri);
                           this.srcVal = valid;
  
  
  
  1.2       +103 -104  xml-cocoon2/lib/core/excalibur-sourceresolve-20030109.jar
  
  	<<Binary file>>
  
  
  1.2       +3 -1      xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/SourceDeferredValidity.java
  
  Index: SourceDeferredValidity.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/SourceDeferredValidity.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SourceDeferredValidity.java	10 Jan 2003 14:19:45 -0000	1.1
  +++ SourceDeferredValidity.java	13 Jan 2003 13:12:30 -0000	1.2
  @@ -50,6 +50,8 @@
   */
   package org.apache.cocoon.components.source.impl;
   
  +import java.io.Serializable;
  +
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceValidity;
   import org.apache.excalibur.source.impl.validity.DeferredValidity;
  
  
  

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