org.apache.cocoon.caching.impl
Class EventAwareCacheImpl

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.caching.impl.CacheImpl
          extended by org.apache.cocoon.caching.impl.EventAwareCacheImpl
All Implemented Interfaces:
Disposable, Initializable, Startable, Component, LogEnabled, Parameterizable, Serviceable, ThreadSafe, Cache, EventAware

public class EventAwareCacheImpl
extends CacheImpl
implements Initializable, Startable, EventAware

This implementation holds all mappings between Events and PipelineCacheKeys in two MultiValueMaps to facilitate efficient lookup by either as Key.

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

Field Summary
 
Fields inherited from class org.apache.cocoon.caching.impl.CacheImpl
manager, store
 
Fields inherited from interface org.apache.cocoon.caching.Cache
ROLE
 
Constructor Summary
EventAwareCacheImpl()
           
 
Method Summary
 void clear()
          Clears the entire Cache, including all registered event-pipeline key mappings..
 void dispose()
          Release resources
 void initialize()
          Get the EventRegistry ready, and make sure it does not contain orphaned Event/PipelineKey mappings.
 void parameterize(Parameters parameters)
           
 void processEvent(Event e)
          Receive notification about the occurrence of an Event.
 void remove(Serializable key)
          Un-register this key in the EventRegistry in addition to removing it from the Store
 void service(ServiceManager manager)
          Look up the EventRegistry
 void start()
          starts cache-cleaner timer task scheduling
 void stop()
          stops cache-cleaner timer task scheduling
 void store(Serializable key, CachedResponse response)
          When a new Pipeline key is stored, it needs to have it's SourceValidity objects examined.
 void verifyEventCache()
          Ensure that all PipelineCacheKeys registered to events still point to valid cache entries.
 
Methods inherited from class org.apache.cocoon.caching.impl.CacheImpl
containsKey, get
 
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
 

Constructor Detail

EventAwareCacheImpl

public EventAwareCacheImpl()
Method Detail

parameterize

public void parameterize(Parameters parameters)
                  throws ParameterException
Specified by:
parameterize in interface Parameterizable
Overrides:
parameterize in class CacheImpl
Throws:
ParameterException

clear

public void clear()
Clears the entire Cache, including all registered event-pipeline key mappings..

Specified by:
clear in interface Cache
Overrides:
clear in class CacheImpl

store

public void store(Serializable key,
                  CachedResponse response)
           throws ProcessingException
When a new Pipeline key is stored, it needs to have it's SourceValidity objects examined. For every EventValidity found, it's Event will be registered with this key in the EventRegistry. AggregatedValidity is handled recursively.

Specified by:
store in interface Cache
Overrides:
store in class CacheImpl
Parameters:
key - the key used by the caching algorithm to identify the request
response - the cached response
Throws:
ProcessingException

service

public void service(ServiceManager manager)
             throws ServiceException
Look up the EventRegistry

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

remove

public void remove(Serializable key)
Un-register this key in the EventRegistry in addition to removing it from the Store

Specified by:
remove in interface Cache
Overrides:
remove in class CacheImpl
Parameters:
key - the key used by the caching algorithm to identify the request

processEvent

public void processEvent(Event e)
Receive notification about the occurrence of an Event. If this event has registered pipeline keys, remove them from the Store and unregister them

Specified by:
processEvent in interface EventAware
Parameters:
e - The Event to be processed.

initialize

public void initialize()
                throws Exception
Get the EventRegistry ready, and make sure it does not contain orphaned Event/PipelineKey mappings.

Specified by:
initialize in interface Initializable
Throws:
Exception

verifyEventCache

public void verifyEventCache()
Ensure that all PipelineCacheKeys registered to events still point to valid cache entries. Having an isTotallyEmpty() on Store might make this less necessary, as the most likely time to discover orphaned entries is at startup. This is because stray events could hang around indefinitely if the cache is removed abnormally or is not configured with persistence.


dispose

public void dispose()
Release resources

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

start

public void start()
           throws Exception
starts cache-cleaner timer task scheduling

Specified by:
start in interface Startable
Throws:
Exception

stop

public void stop()
stops cache-cleaner timer task scheduling

Specified by:
stop in interface Startable


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