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

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.components.pipeline.AbstractProcessingPipeline
          extended by org.apache.cocoon.components.pipeline.impl.BaseCachingProcessingPipeline
              extended by org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline
All Implemented Interfaces:
Poolable, Recyclable, Disposable, Component, Composable, Recomposable, LogEnabled, Parameterizable, ProcessingPipeline
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.html 1304258 2012-03-23 10:09:27Z ilgrosso $
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  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  boolean generatorIsCacheableProcessingComponent
           
protected  String generatorRole
          The role name of the generator
protected  long lockTimeout
          Maximum wait time on a pipeline lock
static String PIPELOCK_PREFIX
           
protected  String readerRole
          The role name of the reader
protected  boolean serializerIsCacheableProcessingComponent
           
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  boolean[] transformerIsCacheableProcessingComponent
           
protected  ArrayList transformerRoles
          The role names of the transfomrers
protected  Store transientStore
          Store for pipeline locks (optional)
 
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, generatorSelector, generatorSource, lastConsumer, manager, newManager, outputBufferSize, parameters, reader, readerMimeType, readerParam, readerSelector, readerSource, serializer, serializerMimeType, serializerParam, serializerSelector, serializerSource, sitemapReaderMimeType, sitemapSerializerMimeType, transformerParams, transformers, transformerSelectors, 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 method defined in subclasses
protected abstract  void connectCachingPipeline(Environment environment)
          Abstract method defined in subclasses
protected  void connectPipeline(Environment environment)
          Connect the pipeline.
protected  void generateCachingKey(Environment environment)
          The components of the pipeline are checked if they are Cacheable.
protected  void generateLock(Environment env, Object key)
          makes the lock (instantiates a new object and puts it into the store)
 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)
          Abstract method defined in subclasses
 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
protected  void releaseLock(Object key)
          releases the lock (notifies it and removes it from the store)
 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.
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.
protected  boolean waitForLock(Environment env, Object key)
           
 
Methods inherited from class org.apache.cocoon.components.pipeline.impl.BaseCachingProcessingPipeline
dispose
 
Methods inherited from class org.apache.cocoon.components.pipeline.AbstractProcessingPipeline
checkIfModified, checkPipeline, compose, connect, getGenerator, getLocation, handleException, informBranchPoint, isInternalError, prepareInternal, prepareInternalErrorHandler, preparePipeline, process, process, processErrorHandler, recompose, release, setErrorHandler, setMimeTypeForReader, setMimeTypeForSerializer, setup, 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

PIPELOCK_PREFIX

public static final String PIPELOCK_PREFIX
See Also:
Constant Field Values

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


generatorIsCacheableProcessingComponent

protected boolean generatorIsCacheableProcessingComponent

serializerIsCacheableProcessingComponent

protected boolean serializerIsCacheableProcessingComponent

transformerIsCacheableProcessingComponent

protected boolean[] transformerIsCacheableProcessingComponent

transientStore

protected Store transientStore
Store for pipeline locks (optional)


lockTimeout

protected long lockTimeout
Maximum wait time on a pipeline lock

Constructor Detail

AbstractCachingProcessingPipeline

public AbstractCachingProcessingPipeline()
Method Detail

cacheResults

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

Throws:
Exception

newComponentCacheKey

protected abstract ComponentCacheKey newComponentCacheKey(int type,
                                                          String role,
                                                          Serializable key)
Abstract method defined in subclasses


connectCachingPipeline

protected abstract void connectCachingPipeline(Environment environment)
                                        throws ProcessingException
Abstract method defined in subclasses

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

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
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
mimeType - Can be null
Throws:
ProcessingException

waitForLock

protected boolean waitForLock(Environment env,
                              Object key)

generateLock

protected void generateLock(Environment env,
                            Object key)
makes the lock (instantiates a new object and puts it into the store)


releaseLock

protected void releaseLock(Object key)
releases the lock (notifies it and removes it from the store)


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-2010 The Apache Software Foundation. All Rights Reserved.