org.apache.cocoon.components.pipeline.impl
Class AbstractCachingProcessingPipeline

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.cocoon.components.pipeline.AbstractProcessingPipeline
          extended byorg.apache.cocoon.components.pipeline.impl.BaseCachingProcessingPipeline
              extended byorg.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline
All Implemented Interfaces:
Disposable, LogEnabled, Parameterizable, Poolable, ProcessingPipeline, Recyclable, Serviceable
Direct Known Subclasses:
CachingPointProcessingPipeline, CachingProcessingPipeline

public abstract class AbstractCachingProcessingPipeline
extends BaseCachingProcessingPipeline

This is the base class for all caching pipeline implementations that check different pipeline components.

Since:
2.1
Version:
$Id: AbstractCachingProcessingPipeline.java 161222 2005-04-13 22:04:23Z vgritsenko $
Author:
Carsten Ziegeler, Michael Melhem

Field Summary
protected  boolean cacheCompleteResponse
          Cache complete response
protected  CachedResponse cachedResponse
          The cached response
protected  boolean completeResponseIsCached
          Complete response is cached
protected  boolean configuredDoSmartCaching
          Default setting for smart caching
protected  boolean doSmartCaching
          Smart caching ?
protected  int firstNotCacheableTransformerIndex
          The index indicating to the first transformer which is not cacheable
protected  int firstProcessedTransformerIndex
          The index indicating the first transformer getting input from the cache
protected  PipelineCacheKey fromCacheKey
          This key indicates the response that is fetched from the cache
protected  String generatorRole
          The role name of the generator
protected  String readerRole
          The role name of the reader
protected  String serializerRole
          The role name of the serializer
protected  PipelineCacheKey toCacheKey
          This key indicates the response that will get into the cache
protected  SourceValidity[] toCacheSourceValidities
          The source validities used for caching
protected  ArrayList transformerRoles
          The role names of the transfomrers
 
Fields inherited from class org.apache.cocoon.components.pipeline.impl.BaseCachingProcessingPipeline
cache, xmlDeserializer, xmlSerializer
 
Fields inherited from class org.apache.cocoon.components.pipeline.AbstractProcessingPipeline
configuration, configuredExpires, configuredOutputBufferSize, expires, generator, generatorParam, generatorSource, lastConsumer, manager, newManager, outputBufferSize, parameters, processor, reader, readerMimeType, readerParam, readerSource, serializer, serializerMimeType, serializerParam, serializerSource, transformerParams, transformers, transformerSources
 
Fields inherited from interface org.apache.cocoon.components.pipeline.ProcessingPipeline
ROLE
 
Constructor Summary
AbstractCachingProcessingPipeline()
           
 
Method Summary
 void addTransformer(String role, String source, Parameters param, Parameters hintParam)
          Add a transformer.
protected abstract  void cacheResults(Environment environment, OutputStream os)
          Abstract methods defined in subclasses
protected abstract  void connectCachingPipeline(Environment environment)
           
protected  void connectPipeline(Environment environment)
          Connect the pipeline.
protected  void generateCachingKey(Environment environment)
          The components of the pipeline are checked if they are Cacheable.
 String getKeyForEventPipeline()
          Return the key for the event pipeline If the "event pipeline" (= the complete pipeline without the serializer) is cacheable and valid, return a key.
 SourceValidity getValidityForEventPipeline()
          Return valid validity objects for the event pipeline.
protected abstract  ComponentCacheKey newComponentCacheKey(int type, String role, Serializable key)
           
 void parameterize(Parameters params)
          Parameterizable Interface - Configuration
protected  boolean processReader(Environment environment)
          Process the pipeline using a reader.
protected  boolean processXMLPipeline(Environment environment)
          Process the given Environment, producing the output.
 void recycle()
          Recyclable Interface
 void setGenerator(String role, String source, Parameters param, Parameters hintParam)
          Set the generator.
 void setReader(String role, String source, Parameters param, String mimeType)
          Set the Reader.
 void setSerializer(String role, String source, Parameters param, Parameters hintParam, String mimeType)
          Set the serializer.
 void setup(Parameters params)
          Setup this component
protected  void setupPipeline(Environment environment)
          Setup the evenet pipeline.
protected  void setupValidities()
          Generate validity objects for the new response
protected  void validatePipeline(Environment environment)
          Calculate the key that can be used to get something from the cache, and handle expires properly.
 
Methods inherited from class org.apache.cocoon.components.pipeline.impl.BaseCachingProcessingPipeline
dispose
 
Methods inherited from class org.apache.cocoon.components.pipeline.AbstractProcessingPipeline
checkIfModified, checkPipeline, connect, getGenerator, getLocation, handleException, informBranchPoint, isInternalError, prepareInternal, prepareInternalErrorHandler, preparePipeline, process, process, processErrorHandler, service, setErrorHandler, setMimeTypeForReader, setMimeTypeForSerializer, setProcessorManager, setupReader
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

generatorRole

protected String generatorRole
The role name of the generator


transformerRoles

protected ArrayList transformerRoles
The role names of the transfomrers


serializerRole

protected String serializerRole
The role name of the serializer


readerRole

protected String readerRole
The role name of the reader


cachedResponse

protected CachedResponse cachedResponse
The cached response


firstProcessedTransformerIndex

protected int firstProcessedTransformerIndex
The index indicating the first transformer getting input from the cache


completeResponseIsCached

protected boolean completeResponseIsCached
Complete response is cached


fromCacheKey

protected PipelineCacheKey fromCacheKey
This key indicates the response that is fetched from the cache


toCacheKey

protected PipelineCacheKey toCacheKey
This key indicates the response that will get into the cache


toCacheSourceValidities

protected SourceValidity[] toCacheSourceValidities
The source validities used for caching


firstNotCacheableTransformerIndex

protected int firstNotCacheableTransformerIndex
The index indicating to the first transformer which is not cacheable


cacheCompleteResponse

protected boolean cacheCompleteResponse
Cache complete response


doSmartCaching

protected boolean doSmartCaching
Smart caching ?


configuredDoSmartCaching

protected boolean configuredDoSmartCaching
Default setting for smart caching

Constructor Detail

AbstractCachingProcessingPipeline

public AbstractCachingProcessingPipeline()
Method Detail

cacheResults

protected abstract void cacheResults(Environment environment,
                                     OutputStream os)
                              throws Exception
Abstract methods defined in subclasses

Throws:
Exception

newComponentCacheKey

protected abstract ComponentCacheKey newComponentCacheKey(int type,
                                                          String role,
                                                          Serializable key)

connectCachingPipeline

protected abstract void connectCachingPipeline(Environment environment)
                                        throws ProcessingException
Throws:
ProcessingException

parameterize

public void parameterize(Parameters params)
                  throws ParameterException
Parameterizable Interface - Configuration

Specified by:
parameterize in interface Parameterizable
Overrides:
parameterize in class BaseCachingProcessingPipeline
Throws:
ParameterException

setup

public void setup(Parameters params)
Setup this component

Specified by:
setup in interface ProcessingPipeline
Overrides:
setup in class AbstractProcessingPipeline

setGenerator

public void setGenerator(String role,
                         String source,
                         Parameters param,
                         Parameters hintParam)
                  throws ProcessingException
Set the generator.

Specified by:
setGenerator in interface ProcessingPipeline
Overrides:
setGenerator in class AbstractProcessingPipeline
Parameters:
role - the generator role in the component manager.
source - the source where to produce XML from, or null if no source is given.
param - the parameters for the generator.
Throws:
ProcessingException - if the generator couldn't be obtained.

addTransformer

public void addTransformer(String role,
                           String source,
                           Parameters param,
                           Parameters hintParam)
                    throws ProcessingException
Add a transformer.

Specified by:
addTransformer in interface ProcessingPipeline
Overrides:
addTransformer in class AbstractProcessingPipeline
Parameters:
role - the transformer role in the component manager.
source - the source used to setup the transformer (e.g. XSL file), or null if no source is given.
param - the parameters for the transfomer.
Throws:
ProcessingException - if the generator couldn't be obtained.

setSerializer

public void setSerializer(String role,
                          String source,
                          Parameters param,
                          Parameters hintParam,
                          String mimeType)
                   throws ProcessingException
Set the serializer.

Specified by:
setSerializer in interface ProcessingPipeline
Overrides:
setSerializer in class AbstractProcessingPipeline
Parameters:
mimeType - Can be null
Throws:
ProcessingException

setReader

public void setReader(String role,
                      String source,
                      Parameters param,
                      String mimeType)
               throws ProcessingException
Set the Reader.

Specified by:
setReader in interface ProcessingPipeline
Overrides:
setReader in class AbstractProcessingPipeline
Parameters:
mimeType - Can be null
Throws:
ProcessingException

processXMLPipeline

protected boolean processXMLPipeline(Environment environment)
                              throws ProcessingException
Process the given Environment, producing the output.

Overrides:
processXMLPipeline in class AbstractProcessingPipeline
Throws:
ProcessingException

generateCachingKey

protected void generateCachingKey(Environment environment)
                           throws ProcessingException
The components of the pipeline are checked if they are Cacheable.

Throws:
ProcessingException

setupValidities

protected void setupValidities()
                        throws ProcessingException
Generate validity objects for the new response

Throws:
ProcessingException

validatePipeline

protected void validatePipeline(Environment environment)
                         throws ProcessingException
Calculate the key that can be used to get something from the cache, and handle expires properly.

Throws:
ProcessingException

setupPipeline

protected void setupPipeline(Environment environment)
                      throws ProcessingException
Setup the evenet pipeline. The components of the pipeline are checked if they are Cacheable.

Overrides:
setupPipeline in class AbstractProcessingPipeline
Throws:
ProcessingException

connectPipeline

protected void connectPipeline(Environment environment)
                        throws ProcessingException
Connect the pipeline.

Overrides:
connectPipeline in class AbstractProcessingPipeline
Throws:
ProcessingException

processReader

protected boolean processReader(Environment environment)
                         throws ProcessingException
Process the pipeline using a reader.

Overrides:
processReader in class AbstractProcessingPipeline
Throws:
ProcessingException - if an error occurs

getValidityForEventPipeline

public SourceValidity getValidityForEventPipeline()
Return valid validity objects for the event pipeline. If the event pipeline (the complete pipeline without the serializer) is cacheable and valid, return all validity objects. Otherwise, return null.

Specified by:
getValidityForEventPipeline in interface ProcessingPipeline
Overrides:
getValidityForEventPipeline in class AbstractProcessingPipeline

getKeyForEventPipeline

public String getKeyForEventPipeline()
Description copied from class: AbstractProcessingPipeline
Return the key for the event pipeline If the "event pipeline" (= the complete pipeline without the serializer) is cacheable and valid, return a key. Otherwise return null

Specified by:
getKeyForEventPipeline in interface ProcessingPipeline
Overrides:
getKeyForEventPipeline in class AbstractProcessingPipeline

recycle

public void recycle()
Recyclable Interface

Specified by:
recycle in interface Recyclable
Overrides:
recycle in class BaseCachingProcessingPipeline


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.