org.apache.cocoon.portal.coplet.adapter.impl
Class CachingURICopletAdapter

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.portal.coplet.adapter.impl.AbstractCopletAdapter
          extended by org.apache.cocoon.portal.coplet.adapter.impl.URICopletAdapter
              extended by org.apache.cocoon.portal.coplet.adapter.impl.CachingURICopletAdapter
All Implemented Interfaces:
Disposable, Initializable, Component, Contextualizable, LogEnabled, Parameterizable, Serviceable, ThreadSafe, CopletAdapter, Receiver
Direct Known Subclasses:
ApplicationCopletAdapter

public class CachingURICopletAdapter
extends URICopletAdapter
implements Parameterizable

This adapter extends the URICopletAdapter by a caching mechanism. The result of the called uri/pipeline is cached until a CopletInstanceEvent for that coplet instance is received. The content can eiter be cached in the user session or globally. The default is the user session.

Version:
$Id: CachingURICopletAdapter.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Gerald Kahrer, Carsten Ziegeler

Field Summary
protected  Cache cache
          The cache to use for global caching.
static String CACHE
          The temporary attribute name for the storing the cached coplet content.
static String CONFIGURATION_CACHE_GLOBAL
          The configuration name for using the global cache.
static String CONFIGURATION_CACHE_GLOBAL_USE_ATTRIBUTES
          The configuration name for querying instance attributes to generate the key for the global cache.
static String CONFIGURATION_ENABLE_CACHING
          The configuration name for enabling/disabling the cache.
static String CONFIGURATION_IGNORE_SIZING_EVENTS
          The configuration name for ignoring sizing events to clear the cache.
static String DO_NOT_CACHE
          This temporary attribute can be set on the instance to not cache the current response.
protected  Boolean enableCaching
          Is caching enabled?
static String PARAMETER_DISABLE_CACHING
          Deprecated. Use coplet base data configuration.
 
Fields inherited from class org.apache.cocoon.portal.coplet.adapter.impl.URICopletAdapter
context, resolver
 
Fields inherited from class org.apache.cocoon.portal.coplet.adapter.impl.AbstractCopletAdapter
manager
 
Fields inherited from interface org.apache.cocoon.portal.coplet.adapter.CopletAdapter
ROLE
 
Constructor Summary
CachingURICopletAdapter()
           
 
Method Summary
 void dispose()
           
protected  String getCacheKey(CopletInstanceData coplet, String uri)
          Build the key for the global cache.
 void handleCopletInstanceEvent(CopletInstanceEvent event)
          This adapter listens for CopletInstanceEvents.
 void inform(CopletInstanceEvent e, PortalService service)
           
protected  boolean isSizingEvent(CopletInstanceEvent event)
          Tests if the event is a sizing event for the coplet.
 void parameterize(Parameters parameters)
           
 void service(ServiceManager manager)
           
 void streamContent(CopletInstanceData coplet, ContentHandler contentHandler)
          Implement this and not toSAX()
 void streamContent(CopletInstanceData coplet, String uri, ContentHandler contentHandler)
           
 
Methods inherited from class org.apache.cocoon.portal.coplet.adapter.impl.URICopletAdapter
contextualize, initialize, renderErrorContent
 
Methods inherited from class org.apache.cocoon.portal.coplet.adapter.impl.AbstractCopletAdapter
destroy, getConfiguration, getConfiguration, init, login, logout, toSAX
 
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

CONFIGURATION_ENABLE_CACHING

public static final String CONFIGURATION_ENABLE_CACHING
The configuration name for enabling/disabling the cache.

See Also:
Constant Field Values

CONFIGURATION_CACHE_GLOBAL

public static final String CONFIGURATION_CACHE_GLOBAL
The configuration name for using the global cache.

See Also:
Constant Field Values

CONFIGURATION_CACHE_GLOBAL_USE_ATTRIBUTES

public static final String CONFIGURATION_CACHE_GLOBAL_USE_ATTRIBUTES
The configuration name for querying instance attributes to generate the key for the global cache.

See Also:
Constant Field Values

CONFIGURATION_IGNORE_SIZING_EVENTS

public static final String CONFIGURATION_IGNORE_SIZING_EVENTS
The configuration name for ignoring sizing events to clear the cache.

See Also:
Constant Field Values

CACHE

public static final String CACHE
The temporary attribute name for the storing the cached coplet content.

See Also:
Constant Field Values

DO_NOT_CACHE

public static final String DO_NOT_CACHE
This temporary attribute can be set on the instance to not cache the current response.

See Also:
Constant Field Values

PARAMETER_DISABLE_CACHING

public static final String PARAMETER_DISABLE_CACHING
Deprecated. Use coplet base data configuration.
Caching can be basically disabled with this boolean parameter.

See Also:
Constant Field Values

enableCaching

protected Boolean enableCaching
Is caching enabled?


cache

protected Cache cache
The cache to use for global caching.

Constructor Detail

CachingURICopletAdapter

public CachingURICopletAdapter()
Method Detail

parameterize

public void parameterize(Parameters parameters)
Specified by:
parameterize in interface Parameterizable
See Also:
Parameterizable.parameterize(org.apache.avalon.framework.parameters.Parameters)

service

public void service(ServiceManager manager)
             throws ServiceException
Specified by:
service in interface Serviceable
Overrides:
service in class URICopletAdapter
Throws:
ServiceException
See Also:
Serviceable.service(org.apache.avalon.framework.service.ServiceManager)

dispose

public void dispose()
Specified by:
dispose in interface Disposable
Overrides:
dispose in class URICopletAdapter
See Also:
Disposable.dispose()

streamContent

public void streamContent(CopletInstanceData coplet,
                          ContentHandler contentHandler)
                   throws SAXException
Description copied from class: AbstractCopletAdapter
Implement this and not toSAX()

Overrides:
streamContent in class URICopletAdapter
Throws:
SAXException
See Also:
AbstractCopletAdapter.streamContent(org.apache.cocoon.portal.coplet.CopletInstanceData, org.xml.sax.ContentHandler)

streamContent

public void streamContent(CopletInstanceData coplet,
                          String uri,
                          ContentHandler contentHandler)
                   throws SAXException
Overrides:
streamContent in class URICopletAdapter
Throws:
SAXException
See Also:
URICopletAdapter.streamContent(org.apache.cocoon.portal.coplet.CopletInstanceData, java.lang.String, org.xml.sax.ContentHandler)

inform

public void inform(CopletInstanceEvent e,
                   PortalService service)
Overrides:
inform in class URICopletAdapter
See Also:
Receiver

handleCopletInstanceEvent

public void handleCopletInstanceEvent(CopletInstanceEvent event)
This adapter listens for CopletInstanceEvents. Each event sets the cache invalid, except for global caching using attributes, as all attributes are part of the cache key.


isSizingEvent

protected boolean isSizingEvent(CopletInstanceEvent event)
Tests if the event is a sizing event for the coplet.


getCacheKey

protected String getCacheKey(CopletInstanceData coplet,
                             String uri)
Build the key for the global cache.



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