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

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

public class CachingURICopletAdapter
extends URICopletAdapter
implements Receiver

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.java 326672 2005-10-19 20:11:10Z cziegeler $

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.
 
Fields inherited from class org.apache.cocoon.portal.coplet.adapter.impl.URICopletAdapter
resolver
 
Fields inherited from class org.apache.cocoon.portal.impl.AbstractComponent
context, manager, portalService
 
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)
           
 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
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.cocoon.portal.impl.AbstractComponent
contextualize, initialize
 
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

cache

protected Cache cache
The cache to use for global caching.

Constructor Detail

CachingURICopletAdapter

public CachingURICopletAdapter()
Method Detail

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)
See Also:
Receiver

handleCopletInstanceEvent

public void handleCopletInstanceEvent(CopletInstanceEvent event)
This adapter listens for CopletInstanceEvents. Each event sets the cache invalid.


getCacheKey

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



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