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

java.lang.Object
  extended byorg.apache.cocoon.util.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, Parameterizable, Poolable, org.apache.cocoon.components.pipeline.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.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Field Summary
protected  boolean cacheCompleteResponse
          Cache complete response
protected  org.apache.cocoon.caching.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  String generatorRole
          The role name of the generator
static String PIPELOCK_PREFIX
           
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  List 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, generatorSource, lastConsumer, manager, newManager, outputBufferSize, parameters, reader, readerMimeType, readerParam, readerSource, serializer, serializerMimeType, serializerParam, serializerSource, sourceResolver, 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  org.apache.cocoon.caching.CachedResponse cacheResults(org.apache.cocoon.environment.Environment environment, OutputStream os)
          Abstract method defined in subclasses
protected abstract  void connectCachingPipeline(org.apache.cocoon.environment.Environment environment)
          Abstract method defined in subclasses
protected  void connectPipeline(org.apache.cocoon.environment.Environment environment)
          Connect the pipeline.
protected  void generateCachingKey(org.apache.cocoon.environment.Environment environment)
          The components of the pipeline are checked if they are Cacheable.
protected  void generateLock(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(org.apache.cocoon.environment.Environment environment)
          Process the pipeline using a reader.
protected  boolean processXMLPipeline(org.apache.cocoon.environment.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(org.apache.cocoon.environment.Environment environment)
          Setup the evenet pipeline.
protected  void setupValidities()
          Generate validity objects for the new response
protected  void validatePipeline(org.apache.cocoon.environment.Environment environment)
          Calculate the key that can be used to get something from the cache, and handle expires properly.
protected  boolean waitForLock(Object key)
          Look up the lock object by key, and if present, wait till notified.
 
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, setup, setupReader
 
Methods inherited from class org.apache.cocoon.util.AbstractLogEnabled
getLogger, setLogger
 
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 List 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 org.apache.cocoon.caching.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


transientStore

protected Store transientStore
Store for pipeline locks (optional)

Constructor Detail

AbstractCachingProcessingPipeline

public AbstractCachingProcessingPipeline()
Method Detail

cacheResults

protected abstract org.apache.cocoon.caching.CachedResponse cacheResults(org.apache.cocoon.environment.Environment environment,
                                                                         OutputStream os)
                                                                  throws Exception
Abstract method defined in subclasses

Returns:
complete cached response or null
See issue COCOON-2009 for discussion
Throws:
Exception

newComponentCacheKey

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


connectCachingPipeline

protected abstract void connectCachingPipeline(org.apache.cocoon.environment.Environment environment)
                                        throws org.apache.cocoon.ProcessingException
Abstract method defined in subclasses

Throws:
org.apache.cocoon.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 org.apache.cocoon.ProcessingException
Set the generator.

Specified by:
setGenerator in interface org.apache.cocoon.components.pipeline.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:
org.apache.cocoon.ProcessingException - if the generator couldn't be obtained.

addTransformer

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

Specified by:
addTransformer in interface org.apache.cocoon.components.pipeline.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:
org.apache.cocoon.ProcessingException - if the generator couldn't be obtained.

setSerializer

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

Specified by:
setSerializer in interface org.apache.cocoon.components.pipeline.ProcessingPipeline
Overrides:
setSerializer in class AbstractProcessingPipeline
Parameters:
mimeType - Can be null
Throws:
org.apache.cocoon.ProcessingException

setReader

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

Specified by:
setReader in interface org.apache.cocoon.components.pipeline.ProcessingPipeline
Overrides:
setReader in class AbstractProcessingPipeline
Parameters:
mimeType - Can be null
Throws:
org.apache.cocoon.ProcessingException

waitForLock

protected boolean waitForLock(Object key)
Look up the lock object by key, and if present, wait till notified.

Returns:
false if able to find a lock and was notified

generateLock

protected void generateLock(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(org.apache.cocoon.environment.Environment environment)
                              throws org.apache.cocoon.ProcessingException
Process the given Environment, producing the output.

Overrides:
processXMLPipeline in class AbstractProcessingPipeline
Throws:
org.apache.cocoon.ProcessingException

generateCachingKey

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

Throws:
org.apache.cocoon.ProcessingException

setupValidities

protected void setupValidities()
                        throws org.apache.cocoon.ProcessingException
Generate validity objects for the new response

Throws:
org.apache.cocoon.ProcessingException

validatePipeline

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

Throws:
org.apache.cocoon.ProcessingException

setupPipeline

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

Overrides:
setupPipeline in class AbstractProcessingPipeline
Throws:
org.apache.cocoon.ProcessingException

connectPipeline

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

Overrides:
connectPipeline in class AbstractProcessingPipeline
Throws:
org.apache.cocoon.ProcessingException

processReader

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

Overrides:
processReader in class AbstractProcessingPipeline
Throws:
org.apache.cocoon.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 org.apache.cocoon.components.pipeline.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 org.apache.cocoon.components.pipeline.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-2008 The Apache Software Foundation. All Rights Reserved.