cziegeler    2003/03/19 07:53:19

  Modified:    src/java/org/apache/cocoon/generation
                        AbstractServerPage.java
  Log:
  Fixing caching problems with XSP
  
  Revision  Changes    Path
  1.3       +50 -2     
cocoon-2.1/src/java/org/apache/cocoon/generation/AbstractServerPage.java
  
  Index: AbstractServerPage.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/AbstractServerPage.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractServerPage.java   19 Mar 2003 15:42:13 -0000      1.2
  +++ AbstractServerPage.java   19 Mar 2003 15:53:19 -0000      1.3
  @@ -54,6 +54,8 @@
   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.CacheableProcessingComponent;
   import org.apache.cocoon.components.language.generator.CompiledComponent;
   import org.apache.cocoon.environment.Request;
  @@ -75,7 +77,8 @@
    * @version CVS $Id$
    */
   public abstract class AbstractServerPage
  -  extends ServletGenerator implements CompiledComponent, 
CacheableProcessingComponent, Recomposable {
  +  extends ServletGenerator 
  +  implements CompiledComponent, CacheableProcessingComponent, Cacheable, 
Recomposable {
       /**
        * Code generators should produce a constructor
        * block that initializes the generator's
  @@ -215,4 +218,49 @@
       protected void comment(String data) throws SAXException {
           this.lexicalHandler.comment(data.toCharArray(), 0, data.length());
       }
  +
  +    /**
  +     * Generates 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
  +     *
  +     * @return A long representing the cache key (defaults to not cachable)
  +     */
  +    public long generateKey() {
  +        return 0;
  +    }
  +
  +    /**
  +     * Generate the validity object.
  +     *
  +     * @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() {
  +        if (hasContentChanged(request))
  +            return null;
  +        else
  +            return NOPCacheValidity.CACHE_VALIDITY;
  +    }
  +
   }
  +
  +/** 
  + * This is here to avaid references to the deprecated package.
  + * It is required to support the deprecated caching algorithm
  + */
  +final class NOPCacheValidity
  +implements CacheValidity {
  +
  +    public static final CacheValidity CACHE_VALIDITY = new NOPCacheValidity();
  +
  +    public boolean isValid(CacheValidity validity) {
  +        return validity instanceof NOPCacheValidity;
  +    }
  +
  +    public String toString() {
  +        return "NOP Validity";
  +    }
  +}
  \ No newline at end of file
  
  
  

Reply via email to