org.apache.cocoon.samples
Class EventAwareGenerator

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.xml.AbstractXMLProducer
          extended by org.apache.cocoon.generation.AbstractGenerator
              extended by org.apache.cocoon.generation.ServiceableGenerator
                  extended by org.apache.cocoon.template.JXTemplateGenerator
                      extended by org.apache.cocoon.samples.EventAwareGenerator
All Implemented Interfaces:
Poolable, Recyclable, Disposable, Component, LogEnabled, Serviceable, CacheableProcessingComponent, Generator, SitemapModelComponent, XMLProducer

public class EventAwareGenerator
extends JXTemplateGenerator

This is a sample generator to demonstrate the event aware caching. We simply extend the JXTG.

Version:
$Id: EventAwareGenerator.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Field Summary
 
Fields inherited from class org.apache.cocoon.template.JXTemplateGenerator
CACHE_KEY, NS, VALIDITY
 
Fields inherited from class org.apache.cocoon.generation.ServiceableGenerator
manager
 
Fields inherited from class org.apache.cocoon.generation.AbstractGenerator
objectModel, parameters, resolver, source
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.generation.Generator
ROLE
 
Constructor Summary
EventAwareGenerator()
           
 
Method Summary
 void generate()
          Generate the XML and stream it into the pipeline
 Serializable getKey()
          Generate the unique key for the cache.
 SourceValidity getValidity()
          Generate the validity object, tells the cache how long to keep contents having this key around.
 
Methods inherited from class org.apache.cocoon.template.JXTemplateGenerator
dispose, getConsumer, performGeneration, recycle, service, setup
 
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
 

Constructor Detail

EventAwareGenerator

public EventAwareGenerator()
Method Detail

getKey

public Serializable getKey()
Generate the unique key for the cache. This key must be unique inside the space of this XSP page, it is used to find the page contents in the cache (if getValidity says that the contents are still valid). This method will be invoked before the getValidity() method.

Specified by:
getKey in interface CacheableProcessingComponent
Overrides:
getKey in class JXTemplateGenerator
Returns:
The generated key or null if the component is currently not cacheable.
See Also:
CacheableProcessingComponent.getKey()

getValidity

public SourceValidity getValidity()
Generate the validity object, tells the cache how long to keep contents having this key around. In this case, it will be until an Event is retrieved matching the NamedEvent created below. Before this method can be invoked the getKey() method will be invoked.

Specified by:
getValidity in interface CacheableProcessingComponent
Overrides:
getValidity in class JXTemplateGenerator
Returns:
The generated validity object or null if the component is currently not cacheable.
See Also:
CacheableProcessingComponent.getValidity()

generate

public void generate()
              throws IOException,
                     SAXException,
                     ProcessingException
Description copied from interface: Generator
Generate the XML and stream it into the pipeline

Specified by:
generate in interface Generator
Overrides:
generate in class JXTemplateGenerator
Throws:
IOException
SAXException
ProcessingException
See Also:
Generator.generate()


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.