org.apache.cocoon.transformation
Class CachingCIncludeTransformer

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.xml.AbstractXMLProducer
              |
              +--org.apache.cocoon.xml.AbstractXMLPipe
                    |
                    +--org.apache.cocoon.transformation.AbstractTransformer
                          |
                          +--org.apache.cocoon.transformation.CachingCIncludeTransformer
All Implemented Interfaces:
Cacheable, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler, org.apache.avalon.framework.logger.Loggable, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable, SitemapModelComponent, Transformer, XMLConsumer, XMLPipe, XMLProducer

public class CachingCIncludeTransformer
extends AbstractTransformer
implements org.apache.avalon.framework.component.Composable, Cacheable

This transformer triggers for the element include in the namespace "http://apache.org/cocoon/include/1.0". The src attribute contains the url which points to an xml resource which is include instead of the element. With the attributes element, ns and prefix it is possible to specify an element which surrounds the included content.

Validity of cached pipelines is calculated not by comparing old and new IncludeCacheValidity objects (as in AggregatedCacheValidity) but by comparing timestamps. Validity object of cached pipeline contain two lists: source urls and timestamps. When it comes to checking validity of cached pipeline we know that generation/transformation steps before CIncludeTransformer are valid (otherwise we would have had discarded cached pipeline already) so source url list of new validity will be the same as of old one. Only timestamps have to be recalculated and compared.

Version:
CVS $Id: CachingCIncludeTransformer.java,v 1.7 2002/02/22 07:03:56 cziegeler Exp $
Author:
Carsten Ziegeler, Maciek Kaminski

Field Summary
static java.lang.String CINCLUDE_INCLUDE_ELEMENT
           
static java.lang.String CINCLUDE_INCLUDE_ELEMENT_ELEMENT_ATTRIBUTE
           
static java.lang.String CINCLUDE_INCLUDE_ELEMENT_NS_ATTRIBUTE
           
static java.lang.String CINCLUDE_INCLUDE_ELEMENT_PREFIX_ATTRIBUTE
           
static java.lang.String CINCLUDE_INCLUDE_ELEMENT_SRC_ATTRIBUTE
           
static java.lang.String CINCLUDE_NAMESPACE_URI
           
protected  IncludeXMLConsumer consumer
          The current IncludeXMLConsumer that ommits start and endDocument events.
protected  IncludeCacheValidity currentCacheValidity
          The current IncludeCacheValidity.
protected  org.apache.avalon.framework.component.ComponentManager manager
          The current ComponentManager.
protected  SourceResolver sourceResolver
          The SourceResolver
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.transformation.Transformer
ROLE
 
Constructor Summary
CachingCIncludeTransformer()
           
 
Method Summary
 void compose(org.apache.avalon.framework.component.ComponentManager manager)
          Composable Interface
 void endDocument()
          Receive notification of the end of a document.
 void endElement(java.lang.String uri, java.lang.String name, java.lang.String raw)
          Receive notification of the end of an element.
 long generateKey()
          Generate the unique key.
 CacheValidity generateValidity()
          Generate the validity object.
protected  IncludeXMLConsumer getConsumer()
           
protected  void processCIncludeElement(java.lang.String src, java.lang.String element, java.lang.String ns, java.lang.String prefix)
           
 void recycle()
          Recycle the component
 void setup(SourceResolver resolver, java.util.Map objectModel, java.lang.String source, org.apache.avalon.framework.parameters.Parameters parameters)
          Setup the component.
 void startElement(java.lang.String uri, java.lang.String name, java.lang.String raw, org.xml.sax.Attributes attr)
          Receive notification of the beginning of an element.
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
characters, comment, endCDATA, endDTD, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDocument, startDTD, startEntity, startPrefixMapping
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
characters, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
 

Field Detail

CINCLUDE_NAMESPACE_URI

public static final java.lang.String CINCLUDE_NAMESPACE_URI

CINCLUDE_INCLUDE_ELEMENT

public static final java.lang.String CINCLUDE_INCLUDE_ELEMENT

CINCLUDE_INCLUDE_ELEMENT_SRC_ATTRIBUTE

public static final java.lang.String CINCLUDE_INCLUDE_ELEMENT_SRC_ATTRIBUTE

CINCLUDE_INCLUDE_ELEMENT_ELEMENT_ATTRIBUTE

public static final java.lang.String CINCLUDE_INCLUDE_ELEMENT_ELEMENT_ATTRIBUTE

CINCLUDE_INCLUDE_ELEMENT_NS_ATTRIBUTE

public static final java.lang.String CINCLUDE_INCLUDE_ELEMENT_NS_ATTRIBUTE

CINCLUDE_INCLUDE_ELEMENT_PREFIX_ATTRIBUTE

public static final java.lang.String CINCLUDE_INCLUDE_ELEMENT_PREFIX_ATTRIBUTE

sourceResolver

protected SourceResolver sourceResolver
The SourceResolver

manager

protected org.apache.avalon.framework.component.ComponentManager manager
The current ComponentManager.

currentCacheValidity

protected IncludeCacheValidity currentCacheValidity
The current IncludeCacheValidity.

consumer

protected IncludeXMLConsumer consumer
The current IncludeXMLConsumer that ommits start and endDocument events.
Constructor Detail

CachingCIncludeTransformer

public CachingCIncludeTransformer()
Method Detail

setup

public void setup(SourceResolver resolver,
                  java.util.Map objectModel,
                  java.lang.String source,
                  org.apache.avalon.framework.parameters.Parameters parameters)
           throws ProcessingException,
                  org.xml.sax.SAXException,
                  java.io.IOException
Setup the component.

compose

public final void compose(org.apache.avalon.framework.component.ComponentManager manager)
                   throws org.apache.avalon.framework.component.ComponentException
Composable Interface
Specified by:
compose in interface org.apache.avalon.framework.component.Composable

recycle

public void recycle()
Recycle the component
Overrides:
recycle in class AbstractXMLProducer

startElement

public void startElement(java.lang.String uri,
                         java.lang.String name,
                         java.lang.String raw,
                         org.xml.sax.Attributes attr)
                  throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the beginning of an element.
Overrides:
startElement in class AbstractXMLPipe
Following copied from class: org.apache.cocoon.xml.AbstractXMLPipe
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
loc - The local name (without prefix), or the empty string if Namespace processing is not being performed.
raw - The raw XML 1.0 name (with prefix), or the empty string if raw names are not available.
a - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.

endElement

public void endElement(java.lang.String uri,
                       java.lang.String name,
                       java.lang.String raw)
                throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the end of an element.
Overrides:
endElement in class AbstractXMLPipe
Following copied from class: org.apache.cocoon.xml.AbstractXMLPipe
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
loc - The local name (without prefix), or the empty string if Namespace processing is not being performed.
raw - The raw XML 1.0 name (with prefix), or the empty string if raw names are not available.

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Description copied from class: AbstractXMLPipe
Receive notification of the end of a document.
Overrides:
endDocument in class AbstractXMLPipe

processCIncludeElement

protected void processCIncludeElement(java.lang.String src,
                                      java.lang.String element,
                                      java.lang.String ns,
                                      java.lang.String prefix)
                               throws org.xml.sax.SAXException

generateKey

public long generateKey()
Generate the unique key. This key must be unique inside the space of this component. CachingCIncludeTransformer always generates the same key since which documents are included depends only on former generation/transformation stages.
Specified by:
generateKey in interface Cacheable
Returns:
The generated key hashes the src

generateValidity

public CacheValidity generateValidity()
Generate the validity object. CachingCIncludeTransformer generates "empty" IncludeCacheValidity and completes it with validity data during transformation. See processCIncludeElement method.
Specified by:
generateValidity in interface Cacheable
Returns:
The generated validity object or null if the component is currently not cacheable.

getConsumer

protected IncludeXMLConsumer getConsumer()


Copyright � 1999-2002 Apache Software Foundation. All Rights Reserved.