cziegeler    02/05/27 05:06:13

  Modified:    src/java/org/apache/cocoon/caching
                        CacheableProcessingComponent.java
               src/java/org/apache/cocoon/components/pipeline/impl
                        CachingProcessingPipeline.java
  Log:
  Switching new caching interface to strings (for know...)
  
  Revision  Changes    Path
  1.3       +3 -3      
xml-cocoon2/src/java/org/apache/cocoon/caching/CacheableProcessingComponent.java
  
  Index: CacheableProcessingComponent.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/caching/CacheableProcessingComponent.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CacheableProcessingComponent.java 6 May 2002 13:22:31 -0000       1.2
  +++ CacheableProcessingComponent.java 27 May 2002 12:06:12 -0000      1.3
  @@ -59,7 +59,7 @@
    *
    * @since @next-version@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Id: CacheableProcessingComponent.java,v 1.2 2002/05/06 13:22:31 
cziegeler Exp $
  + * @version CVS $Id: CacheableProcessingComponent.java,v 1.3 2002/05/27 12:06:12 
cziegeler Exp $
    */
   public interface CacheableProcessingComponent {
   
  @@ -68,10 +68,10 @@
        * This key must be unique inside the space of this component.
        * This method must be invoked before the generateValidity() method.
        *
  -     * @return The generated key or <code>0</code> if the component
  +     * @return The generated key or <code>null</code> if the component
        *              is currently not cacheable.
        */
  -    long generateKey();
  +    String generateKey();
   
       /**
        * Generate the validity object.
  
  
  
  1.12      +37 -14    
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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- CachingProcessingPipeline.java    27 May 2002 10:06:40 -0000      1.11
  +++ CachingProcessingPipeline.java    27 May 2002 12:06:13 -0000      1.12
  @@ -89,7 +89,7 @@
    *
    * @since @next-version@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Id: CachingProcessingPipeline.java,v 1.11 2002/05/27 10:06:40 
cziegeler Exp $
  + * @version CVS $Id: CachingProcessingPipeline.java,v 1.12 2002/05/27 12:06:13 
cziegeler Exp $
    */
   public class CachingProcessingPipeline
   extends AbstractProcessingPipeline
  @@ -279,22 +279,27 @@
   
           // is the generator cacheable?
           long key = 0;
  +        String stringKey = null;
           boolean generatorIsCacheableProcessingComponent = false;
           boolean serializerIsCacheableProcessingComponent = false;
           boolean[] transformerIsCacheableProcessingComponent = new 
boolean[this.transformers.size()];
   
           if (this.generator instanceof CacheableProcessingComponent) {
  -            key = ((CacheableProcessingComponent)this.generator).generateKey();
  +            stringKey = 
((CacheableProcessingComponent)this.generator).generateKey();
               generatorIsCacheableProcessingComponent = true;
           } else if (this.generator instanceof Cacheable) {
               key = ((Cacheable)this.generator).generateKey();
           }
   
  -        if (key != 0) {
  +        if (key != 0 || stringKey != null) {
               this.pipelineCacheKey = new StringBuffer();
               this.pipelineCacheKey.append("PCK:CCK:1-")
  -                                 .append(this.generatorRole).append('-')
  -                                 .append(key);
  +                                 .append(this.generatorRole).append('-');
  +            if (key != 0) {
  +                this.pipelineCacheKey.append(key);
  +            } else {
  +                this.pipelineCacheKey.append( stringKey );
  +            }
   
               // now testing transformers
               final int transformerSize = this.transformers.size();
  @@ -305,17 +310,22 @@
                   final Transformer trans =
                       
(Transformer)this.transformers.get(this.firstNotCacheableTransformerIndex);
                   key = 0;
  +                stringKey = null;
                   if (trans instanceof CacheableProcessingComponent) {
  -                    key = ((CacheableProcessingComponent)trans).generateKey();
  +                    stringKey = ((CacheableProcessingComponent)trans).generateKey();
                       
transformerIsCacheableProcessingComponent[this.firstNotCacheableTransformerIndex] = 
true;
                   } else if (trans instanceof Cacheable) {
                       key = ((Cacheable)trans).generateKey();
                   }
  -                if (key != 0) {
  +                if (key != 0 || stringKey != null) {
                       this.pipelineCacheKey.append("CCK:2-")
                                            
.append((String)this.transformerRoles.get(this.firstNotCacheableTransformerIndex))
  -                                         .append('-')
  -                                         .append(key);
  +                                         .append('-');
  +                    if (key != 0) {
  +                        this.pipelineCacheKey.append(key);
  +                    } else {
  +                        this.pipelineCacheKey.append( stringKey );
  +                    }
                       this.firstNotCacheableTransformerIndex++;
                   } else {
                       continueTest = false;
  @@ -325,8 +335,10 @@
               if (this.firstNotCacheableTransformerIndex == transformerSize
                   && this.serializer == this.lastConsumer) {
   
  +                key = 0;
  +                stringKey = null;
                   if (this.serializer instanceof CacheableProcessingComponent) {
  -                    key = 
((CacheableProcessingComponent)this.serializer).generateKey();
  +                    stringKey = 
((CacheableProcessingComponent)this.serializer).generateKey();
                       serializerIsCacheableProcessingComponent = true;
                   } else if (this.serializer instanceof Cacheable) {
                       key = ((Cacheable)this.serializer).generateKey();
  @@ -337,6 +349,12 @@
                                            .append('-')
                                            .append(key);
                       this.completeResponseIsCached = true;
  +                } else if (stringKey != null) {
  +                    this.pipelineCacheKey.append("CCK:3-")
  +                                         .append(this.serializerRole)
  +                                         .append('-')
  +                                         .append(stringKey);
  +                    this.completeResponseIsCached = true;
                   }
               }
           }
  @@ -569,20 +587,25 @@
   
               // test if reader is cacheable
               long readerKey = 0;
  +            String readerStringKey = null;
               boolean isCacheableProcessingComponent = false;
               if (this.reader instanceof CacheableProcessingComponent) {
  -                readerKey = 
((CacheableProcessingComponent)this.reader).generateKey();
  +                readerStringKey = 
((CacheableProcessingComponent)this.reader).generateKey();
                   isCacheableProcessingComponent = true;
               } else if (this.reader instanceof Cacheable) {
                   readerKey = ((Cacheable)this.reader).generateKey();
               }
   
  -            if ( readerKey != 0) {
  +            if ( readerKey != 0 || readerStringKey != null) {
                   // response is cacheable, build the key
                   pcKey = new StringBuffer();
                   pcKey.append("PCK:CCK:4-").append(this.readerRole)
  -                                          .append('-')
  -                                          .append(readerKey);
  +                                          .append('-');
  +                if (readerKey != 0) {
  +                    pcKey.append(readerKey);
  +                } else {
  +                    pcKey.append(readerStringKey);
  +                }
   
                   // now we have the key to get the cached object
                   CachedResponse cachedObject = 
(CachedResponse)this.cache.get(pcKey.toString());
  
  
  

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