org.apache.cocoon.samples
Class EventAwareGenerator

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.cocoon.xml.AbstractXMLProducer
          extended byorg.apache.cocoon.generation.AbstractGenerator
              extended byorg.apache.cocoon.generation.ServiceableGenerator
                  extended byorg.apache.cocoon.template.JXTemplateGenerator
                      extended byorg.apache.cocoon.samples.EventAwareGenerator
All Implemented Interfaces:
CacheableProcessingComponent, Disposable, Generator, LogEnabled, Poolable, Recyclable, Serviceable, 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.java 170002 2005-05-13 09:38:12Z cziegeler $

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.

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.

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


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.