stephan     2002/08/08 00:47:36

  Modified:    src/java/org/apache/cocoon/generation
                        AbstractServerPage.java ServerPagesGenerator.java
  Log:
  Replaced Cacheable through CacheableProcessingComponent
  
  Revision  Changes    Path
  1.9       +18 -13    
xml-cocoon2/src/java/org/apache/cocoon/generation/AbstractServerPage.java
  
  Index: AbstractServerPage.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/AbstractServerPage.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AbstractServerPage.java   7 Apr 2002 18:48:12 -0000       1.8
  +++ AbstractServerPage.java   8 Aug 2002 07:47:36 -0000       1.9
  @@ -54,15 +54,18 @@
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.ComponentException;
   
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.NOPCacheValidity;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.components.language.generator.CompiledComponent;
   import org.apache.cocoon.environment.Request;
  +
  +import org.apache.excalibur.source.SourceValidity;
  +import org.apache.excalibur.source.impl.validity.NOPValidity;
  +
   import org.xml.sax.SAXException;
   import org.xml.sax.helpers.AttributesImpl;
   
   import java.io.File;
  +import java.io.Serializable;
   
   /**
    * Base implementation of <code>ServerPagesGenerator</code>. This class
  @@ -72,7 +75,7 @@
    * @version CVS $Id$
    */
   public abstract class AbstractServerPage
  -  extends ServletGenerator implements CompiledComponent, Cacheable, 
Recomposable {
  +  extends ServletGenerator implements CompiledComponent, 
CacheableProcessingComponent, Recomposable {
       /**
        * Code generators should produce a static
        * block that initializes the generator's
  @@ -135,29 +138,31 @@
       }
   
       /**
  -     * Generates the unique key.
  +     * Generate the unique key.
        * This key must be unique inside the space of this component.
  -     * Users may override this method to take
  -     * advantage of SAX event cacheing
  +     * This method must be invoked before the generateValidity() method.
        *
  -     * @return A long representing the cache key (defaults to not cachable)
  +     * @return The generated key or <code>null</code> if the component
  +     *         is currently not cacheable.
        */
  -    public long generateKey() {
  -        return 0;
  +    public Serializable generateKey() {
  +        return null;
       }
   
       /**
        * Generate the validity object.
  +     * Before this method can be invoked the generateKey() method
  +     * must be invoked.
        *
        * @return The generated validity object, <code>NOPCacheValidity</code>
        *         is the default if hasContentChange() gives false otherwise
        *         <code>null</code> will be returned.
        */
  -    public CacheValidity generateValidity() {
  +    public SourceValidity generateValidity() {
           if (hasContentChanged(request))
               return null;
           else
  -            return NOPCacheValidity.CACHE_VALIDITY;
  +            return NOPValidity.SHARED_INSTANCE;
       }
   
       // FIXME: Add more methods!
  
  
  
  1.19      +20 -14    
xml-cocoon2/src/java/org/apache/cocoon/generation/ServerPagesGenerator.java
  
  Index: ServerPagesGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/ServerPagesGenerator.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ServerPagesGenerator.java 31 Jul 2002 13:13:29 -0000      1.18
  +++ ServerPagesGenerator.java 8 Aug 2002 07:47:36 -0000       1.19
  @@ -63,21 +63,22 @@
   
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.ResourceNotFoundException;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  -import org.apache.cocoon.caching.CompositeCacheValidity;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.components.language.generator.ProgramGenerator;
   import org.apache.cocoon.components.source.SourceUtil;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.util.HashUtil;
   import org.apache.cocoon.xml.AbstractXMLPipe;
  +
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceException;
  +import org.apache.excalibur.source.SourceValidity;
   
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   
   import java.io.IOException;
  +import java.io.Serializable;
   import java.util.HashMap;
   import java.util.Map;
   
  @@ -100,7 +101,7 @@
    * @version CVS $Id$
    */
   public class ServerPagesGenerator extends ServletGenerator
  -        implements Disposable, Cacheable, Configurable {
  +        implements Disposable, CacheableProcessingComponent, Configurable {
       /**
        * The sitemap-defined server pages program generator
        */
  @@ -141,24 +142,29 @@
       }
   
       /**
  -     * Generates the unique key.
  +     * Generate the unique key.
        * This key must be unique inside the space of this component.
  -     * Users may override this method to take
  -     * advantage of SAX event cacheing
  +     * This method must be invoked before the generateValidity() method.
        *
  -     * @return A long representing the cache key (defaults to not cachable)
  +     * @return The generated key or <code>null</code> if the component
  +     *         is currently not cacheable.
        */
  -    public long generateKey() {
  -        return HashUtil.hash(this.inputSource.getSystemId() + '-' + 
generator.generateKey());
  +    public Serializable generateKey() {
  +        Object generatorkey = generator.generateKey();
  +        if (generatorkey==null)
  +            return this.inputSource.getSystemId();
  +        return this.inputSource.getSystemId() + '-' + generatorkey;
       }
  -
  +    
       /**
        * Generate the validity object.
  +     * Before this method can be invoked the generateKey() method
  +     * must be invoked.
        *
        * @return The generated validity object or <code>null</code> if the
  -     *         component is currently not cachable.
  +     *         component is currently not cacheable.
        */
  -    public CacheValidity generateValidity() {
  +    public SourceValidity generateValidity() {
           // VG: Input source's systemID is part of the key,
           // and need not be included into the validity.
           return generator.generateValidity();
  
  
  

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