org.apache.cocoon.generation
Class EventCacheGenerator

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.generation.EventCacheGenerator
All Implemented Interfaces:
Poolable, Recyclable, Disposable, Component, Configurable, LogEnabled, Serviceable, CacheableProcessingComponent, Generator, SitemapModelComponent, XMLProducer

public class EventCacheGenerator
extends ServiceableGenerator
implements Configurable, CacheableProcessingComponent

Generator wrapper that forwards generation to to its delegate but overides its caching strategy by replacing it with an event-cache aware implementation.

Sitemap configuration is as follows:
<map:generator name="event-cache" src="org.apache.cocoon.generation.EventCacheGenerator" >
  <factory name="my-event" value="com.my.EventFactoryImpl" />
  <factory name="my-other-event" value="com.myother.EventFactoryImpl" />
</map:generator>

Two event types are preconfigured: NamedEvent (name="named") and NameValueEvent (name="name-value").

Pipeline usage is as follows:
<map:generate type="event-cache" src="delegate-src">
  <map:parameter name="delegate" value="delegate-type" />
  <map:parameter name="event-type" value="my-event" />
  <!-- my event parameters -->
  <map:parameter name="event-name" value="some name" />
  <map:parameter name="event-value" value="some value" />
</map:generate>

The two preconfigured event types take the following parameters:
- event-type 'named': parameter 'event-name'
- event-type 'name-value': parameter 'event-name' and parameter 'event-value'

The src attribute and all parameters are passed as is to delegate generator.

TODO: share common code with EventCacheTransformer

Author:
Unico Hommes

Field Summary
static String DELEGATE_PARAM
           
static String EVENT_TYPE_DEFAULT
           
static String EVENT_TYPE_PARAM
           
static String FACTORY_CONF
           
static String FACTORY_NAME_CONF
           
static String FACTORY_NAME_TYPE
           
static String NAME_VALUE_EVENT_TYPE
           
static String NAMED_EVENT_TYPE
           
 
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
EventCacheGenerator()
           
 
Method Summary
 void configure(Configuration configuration)
           
 void dispose()
          Release all resources.
 void generate()
          Generate the XML and stream it into the pipeline
 Serializable getKey()
          Generate the unique key.
 SourceValidity getValidity()
          Generate the validity object.
 void recycle()
          Recycle the generator by removing references
 void service(ServiceManager manager)
          Set the current ServiceManager instance used by this Serviceable.
 void setConsumer(XMLConsumer consumer)
          Set the XMLConsumer that will receive XML data.
 void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
          Set the SourceResolver, object model Map, the source and sitemap Parameters used to process the request.
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
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
 

Field Detail

NAME_VALUE_EVENT_TYPE

public static final String NAME_VALUE_EVENT_TYPE
See Also:
Constant Field Values

EVENT_TYPE_DEFAULT

public static final String EVENT_TYPE_DEFAULT
See Also:
Constant Field Values

NAMED_EVENT_TYPE

public static final String NAMED_EVENT_TYPE
See Also:
Constant Field Values

FACTORY_CONF

public static final String FACTORY_CONF
See Also:
Constant Field Values

FACTORY_NAME_CONF

public static final String FACTORY_NAME_CONF
See Also:
Constant Field Values

FACTORY_NAME_TYPE

public static final String FACTORY_NAME_TYPE
See Also:
Constant Field Values

DELEGATE_PARAM

public static final String DELEGATE_PARAM
See Also:
Constant Field Values

EVENT_TYPE_PARAM

public static final String EVENT_TYPE_PARAM
See Also:
Constant Field Values
Constructor Detail

EventCacheGenerator

public EventCacheGenerator()
Method Detail

service

public void service(ServiceManager manager)
             throws ServiceException
Description copied from class: ServiceableGenerator
Set the current ServiceManager instance used by this Serviceable.

Specified by:
service in interface Serviceable
Overrides:
service in class ServiceableGenerator
Throws:
ServiceException

configure

public void configure(Configuration configuration)
               throws ConfigurationException
Specified by:
configure in interface Configurable
Throws:
ConfigurationException

setup

public void setup(SourceResolver resolver,
                  Map objectModel,
                  String src,
                  Parameters par)
           throws ProcessingException,
                  SAXException,
                  IOException
Description copied from class: AbstractGenerator
Set the SourceResolver, object model Map, the source and sitemap Parameters used to process the request.

Specified by:
setup in interface SitemapModelComponent
Overrides:
setup in class AbstractGenerator
Throws:
ProcessingException
SAXException
IOException

setConsumer

public void setConsumer(XMLConsumer consumer)
Description copied from class: AbstractXMLProducer
Set the XMLConsumer that will receive XML data.
This method will simply call setContentHandler(consumer) and setLexicalHandler(consumer).

Specified by:
setConsumer in interface XMLProducer
Overrides:
setConsumer in class AbstractXMLProducer

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
Throws:
IOException
SAXException
ProcessingException

recycle

public void recycle()
Description copied from class: AbstractGenerator
Recycle the generator by removing references

Specified by:
recycle in interface Recyclable
Overrides:
recycle in class AbstractGenerator

getKey

public Serializable getKey()
Description copied from interface: CacheableProcessingComponent
Generate the unique key. This key must be unique inside the space of this component. This method must be invoked before the getValidity() method.

Specified by:
getKey in interface CacheableProcessingComponent
Returns:
The generated key or null if the component is currently not cacheable.

getValidity

public SourceValidity getValidity()
Description copied from interface: CacheableProcessingComponent
Generate the validity object. Before this method can be invoked the getKey() method must be invoked.

Specified by:
getValidity in interface CacheableProcessingComponent
Returns:
The generated validity object or null if the component is currently not cacheable.

dispose

public void dispose()
Description copied from class: ServiceableGenerator
Release all resources.

Specified by:
dispose in interface Disposable
Overrides:
dispose in class ServiceableGenerator


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