You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2004/03/07 19:44:14 UTC

cvs commit: cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/pipeline/impl ExpiresCachingProcessingPipeline.java

cziegeler    2004/03/07 10:44:14

  Modified:    src/blocks/scratchpad/java/org/apache/cocoon/components/pipeline/impl
                        ExpiresCachingProcessingPipeline.java
  Log:
  Making the expires pipeline impl parameterizable
  
  Revision  Changes    Path
  1.4       +18 -4     cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/pipeline/impl/ExpiresCachingProcessingPipeline.java
  
  Index: ExpiresCachingProcessingPipeline.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/scratchpad/java/org/apache/cocoon/components/pipeline/impl/ExpiresCachingProcessingPipeline.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ExpiresCachingProcessingPipeline.java	5 Mar 2004 10:07:25 -0000	1.3
  +++ ExpiresCachingProcessingPipeline.java	7 Mar 2004 18:44:14 -0000	1.4
  @@ -21,6 +21,8 @@
   import java.util.Map;
   
   import org.apache.avalon.framework.component.ComponentException;
  +import org.apache.avalon.framework.parameters.ParameterException;
  +import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ConnectionResetException;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.caching.CachedResponse;
  @@ -40,7 +42,9 @@
    * This pipeline implementation caches the complete content for a defined
    * period of time (expires). 
    * 
  - * <map:pipe name="expires" src="org.apache.cocoon.components.pipeline.impl.ExpiresCachingProcessingPipeline"/>
  + * <map:pipe name="expires" src="org.apache.cocoon.components.pipeline.impl.ExpiresCachingProcessingPipeline">
  + *   <parameter name="cache-expires" value="180"/> <!-- Expires in secondes -->
  + * </map:pipe>
    * 
    * @since 2.1
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  @@ -62,11 +66,21 @@
       protected SimpleCacheKey cacheKey;
       
       /** The expires information */
  -    protected long           cacheExpires;
  +    protected long cacheExpires;
  +    
  +    /** Default value for expiration */
  +    protected long defaultCacheExpires = 3600; // 1 hour
       
       /** The cached response */
       protected CachedResponse cachedResponse;
       
  +    public void parameterize(Parameters params)
  +    throws ParameterException {
  +        super.parameterize(params);
  +        
  +        this.defaultCacheExpires = params.getParameterAsLong("cache-expires", this.defaultCacheExpires);
  +    }
  +
       /**
        * Process the given <code>Environment</code>, producing the output.
        */
  @@ -211,7 +225,7 @@
           }
           String expiresValue = (String)objectModel.get(CACHE_EXPIRES_KEY);
           if ( expiresValue == null ) {
  -            this.cacheExpires = this.parameters.getParameterAsLong("cache-expires", 0);
  +            this.cacheExpires = this.parameters.getParameterAsLong("cache-expires", this.defaultCacheExpires);
           } else {
               this.cacheExpires = Long.valueOf(expiresValue).longValue();
               objectModel.remove(CACHE_EXPIRES_KEY);