|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.xml.AbstractXMLProducer
org.apache.cocoon.xml.AbstractXMLPipe
org.apache.cocoon.transformation.AbstractTransformer
org.apache.cocoon.transformation.AbstractSAXTransformer
org.apache.cocoon.transformation.CIncludeTransformer
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.cached-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.
First, it works like the usual include command. But it can be
configured with various parameters:
The most important one is the expires
parameter.
If (and only if) this is set to a value greater than zero,
all included content is cached for the given period of time.
So if any other request includes the same URI, the content
is fetched from the cache. The expires value is in seconds.
Usually the content is cached in the usual store, but you
can also define a writeable source with the source
parameter,
e.g. "file:/c:/temp". Then the cached content is written into this
directory.
With the optional purge
set to true
the cache is purged which means the cached content is regarded as
invalid nevertheless if it has expired or not.
With the optional parameter parallel
the various
included contents are processed (included) in parallel rather than
in a series.
With the optional parameter preemptive
set to true
a pre-emptive caching is activated. When a resource is requested with
pre-emptive caching, this transformer always attempts to get the
content from the cache. If the content is not in the cache, it is
of course retrieved from the original source and cached.
If the cached resource has expired, it is still provided. The cache
is updated by a background task. This task has to be started
beforehand.Fields inherited from class org.apache.cocoon.transformation.AbstractSAXTransformer |
context, defaultNamespaceURI, EMPTY_ATTRIBUTES, ignoreEmptyCharacters, ignoreEventsCount, ignoreHooksCount, ignoreWhitespaces, manager, namespaceURI, objectModel, parameters, recorderStack, request, resolver, response, source, stack |
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer |
Fields inherited from interface org.apache.cocoon.transformation.Transformer |
ROLE |
Constructor Summary | |
CIncludeTransformer()
Constructor Set the namespace |
Method Summary | |
void |
dispose()
|
protected Object |
endCompiledXMLRecording()
Stop recording of compiled XML. |
void |
endDocument()
Process the SAX event. |
void |
endTransformingElement(String uri,
String name,
String raw)
Start processing elements of our namespace. |
Serializable |
getKey()
Generate the unique key for the resource being rendered. |
SourceValidity |
getValidity()
Generate the validity object. |
protected String |
processCIncludeElement(String src,
String element,
String select,
String ns,
String prefix,
boolean stripRoot,
boolean cache)
|
void |
recycle()
Recycle the component |
void |
service(ServiceManager manager)
|
void |
setup(SourceResolver resolver,
Map objectModel,
String source,
Parameters parameters)
Setup the component. |
protected void |
startCompiledXMLRecording()
Start recording of compiled xml. |
void |
startDocument()
Process the SAX event. |
void |
startTransformingElement(String uri,
String name,
String raw,
Attributes attr)
Start processing elements of our namespace. |
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
setConsumer, setContentHandler, setLexicalHandler |
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 |
Methods inherited from interface org.apache.cocoon.xml.XMLProducer |
setConsumer |
Field Detail |
public static final String CINCLUDE_NAMESPACE_URI
public static final String CINCLUDE_INCLUDE_ELEMENT
public static final String CINCLUDE_INCLUDE_ELEMENT_SRC_ATTRIBUTE
public static final String CINCLUDE_INCLUDE_ELEMENT_ELEMENT_ATTRIBUTE
public static final String CINCLUDE_INCLUDE_ELEMENT_SELECT_ATTRIBUTE
public static final String CINCLUDE_INCLUDE_ELEMENT_NS_ATTRIBUTE
public static final String CINCLUDE_INCLUDE_ELEMENT_PREFIX_ATTRIBUTE
public static final String CINCLUDE_INCLUDE_ELEMENT_STRIP_ROOT_ATTRIBUTE
public static final String CINCLUDE_INCLUDEXML_ELEMENT
public static final String CINCLUDE_INCLUDEXML_ELEMENT_IGNORE_ERRORS_ATTRIBUTE
public static final String CINCLUDE_SRC_ELEMENT
public static final String CINCLUDE_CONFIGURATION_ELEMENT
public static final String CINCLUDE_PARAMETERS_ELEMENT
public static final String CINCLUDE_PARAMETER_ELEMENT
public static final String CINCLUDE_NAME_ELEMENT
public static final String CINCLUDE_VALUE_ELEMENT
public static final String CINCLUDE_CACHED_INCLUDE_ELEMENT
protected static final String CINCLUDE_CACHED_INCLUDE_PLACEHOLDER_ELEMENT
protected Parameters configurationParameters
protected SourceParameters resourceParameters
protected int state
protected IncludeCacheManager cacheManager
protected IncludeCacheManagerSession cachingSession
protected boolean compiling
protected IncludeXMLConsumer filter
protected XMLSerializer recorder
protected AttributesImpl srcAttributes
protected boolean supportCaching
protected long startTime
Constructor Detail |
public CIncludeTransformer()
Method Detail |
public void setup(SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws ProcessingException, SAXException, IOException
setup
in interface SitemapModelComponent
setup
in class AbstractSAXTransformer
ProcessingException
SAXException
IOException
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
service
in class AbstractSAXTransformer
ServiceException
Serviceable.service(org.apache.avalon.framework.service.ServiceManager)
public void dispose()
dispose
in interface Disposable
dispose
in class AbstractSAXTransformer
Disposable.dispose()
public void recycle()
recycle
in interface Recyclable
recycle
in class AbstractSAXTransformer
public void startTransformingElement(String uri, String name, String raw, Attributes attr) throws ProcessingException, IOException, SAXException
AbstractSAXTransformer
startTransformingElement
in class AbstractSAXTransformer
uri
- The namespace of the element.name
- The local name of the element.raw
- The qualified name of the element.attr
- The attributes of the element.
ProcessingException
IOException
SAXException
public void endTransformingElement(String uri, String name, String raw) throws ProcessingException, IOException, SAXException
AbstractSAXTransformer
endTransformingElement
in class AbstractSAXTransformer
uri
- The namespace of the element.name
- The local name of the element.raw
- The qualified name of the element.
ProcessingException
IOException
SAXException
protected String processCIncludeElement(String src, String element, String select, String ns, String prefix, boolean stripRoot, boolean cache) throws SAXException, IOException
SAXException
IOException
protected void startCompiledXMLRecording() throws SAXException
SAXException
protected Object endCompiledXMLRecording() throws SAXException
SAXException
public void startDocument() throws SAXException
AbstractSAXTransformer
AbstractSAXTransformer.setupTransforming()
is invoked.
startDocument
in interface ContentHandler
startDocument
in class AbstractSAXTransformer
SAXException
ContentHandler.startDocument()
public void endDocument() throws SAXException
AbstractSAXTransformer
endDocument
in interface ContentHandler
endDocument
in class AbstractSAXTransformer
SAXException
ContentHandler.endDocument()
public Serializable getKey()
CacheableProcessingComponent
The cache key is the single most important part of the caching implementation. If you don't get it right, you can introduce more load on the caching engine than is necessary. It is important that the cache key has the following attributes:
Thankfully there is a perfectly suitable object that satisfies these
obligations from Java's core: java.lang.String
. You can
also use your own specific key objects provided they respect the above
contracts.
Important:If the cache key is null
then
your component will not be cached at all. You can use this to your
advantage to cache some things but not others.
getKey
in interface CacheableProcessingComponent
null
if the component
is currently not cacheable.CacheableProcessingComponent.getKey()
public SourceValidity getValidity()
CacheableProcessingComponent
getKey()
method.
The caching contracts use the Excalibur SourceValidity
interface to determine whether a resource is valid or not. The validity
can be a compound check that incorporates time since creation, parameter
values, etc. As long as the sitemap can determine whether the cached
resource is valid or not. More information is available on the
Apache
Excalibur site. Alternatively you can use the built in
CacheValidity
objects in the
org.apache.cocoon.caching
package and then use the
CacheValidityToSourceValidity
adaptor object.
getValidity
in interface CacheableProcessingComponent
null
if the
component is currently not cacheable.CacheableProcessingComponent.getValidity()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |