ghoward 2003/10/01 21:21:17 Modified: src/blocks/eventcache/java/org/apache/cocoon/caching/impl DefaultEventRegistryImpl.java EventAwareCacheImpl.java src/blocks/eventcache/java/org/apache/cocoon/acting CacheEventAction.java src/blocks/eventcache/samples sitemap.xmap event.js eventcache.xsp src/blocks/eventcache/java/org/apache/cocoon/caching EventRegistry.java Log: Fix event cache samples. Revision Changes Path 1.7 +9 -9 cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/DefaultEventRegistryImpl.java Index: DefaultEventRegistryImpl.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/DefaultEventRegistryImpl.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- DefaultEventRegistryImpl.java 24 Sep 2003 21:22:33 -0000 1.6 +++ DefaultEventRegistryImpl.java 2 Oct 2003 04:21:17 -0000 1.7 @@ -57,6 +57,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.io.Serializable; import java.util.Collection; import java.util.Iterator; import java.util.Set; @@ -70,7 +71,6 @@ import org.apache.avalon.framework.thread.ThreadSafe; import org.apache.cocoon.Constants; import org.apache.cocoon.caching.EventRegistry; -import org.apache.cocoon.caching.PipelineCacheKey; import org.apache.cocoon.caching.validity.Event; import org.apache.commons.collections.MultiHashMap; @@ -105,7 +105,7 @@ * @param event The event to * @param key */ - public void register(Event e, PipelineCacheKey key) { + public void register(Event e, Serializable key) { synchronized(this) { m_keyMMap.put(key,e); m_eventMMap.put(e,key); @@ -125,7 +125,7 @@ /** * Retrieve all pipeline keys mapped to this event. */ - public PipelineCacheKey[] keysForEvent(Event e) { + public Serializable[] keysForEvent(Event e) { Collection coll = (Collection)m_eventMMap.get(e); if (coll==null || coll.isEmpty()) { if (getLogger().isDebugEnabled()) { @@ -133,24 +133,24 @@ } return null; } else { - return (PipelineCacheKey[])coll.toArray(new PipelineCacheKey[coll.size()]); + return (Serializable[])coll.toArray(new Serializable[coll.size()]); } } /** * Return all pipeline keys mapped to any event */ - public PipelineCacheKey[] allKeys() { + public Serializable[] allKeys() { Set keys = this.m_keyMMap.keySet(); - return (PipelineCacheKey[])keys.toArray( - new PipelineCacheKey[keys.size()]); + return (Serializable[])keys.toArray( + new Serializable[keys.size()]); } /** * When a CachedResponse is removed from the Cache, any entries * in the event mapping must be cleaned up. */ - public void removeKey(PipelineCacheKey key) { + public void removeKey(Serializable key) { Collection coll = (Collection)m_keyMMap.get(key); if (coll==null || coll.isEmpty()) { return; 1.6 +29 -19 cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/EventAwareCacheImpl.java Index: EventAwareCacheImpl.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/impl/EventAwareCacheImpl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- EventAwareCacheImpl.java 5 Sep 2003 04:02:51 -0000 1.5 +++ EventAwareCacheImpl.java 2 Oct 2003 04:21:17 -0000 1.6 @@ -45,6 +45,7 @@ */ package org.apache.cocoon.caching.impl; +import java.io.Serializable; import java.util.Iterator; import org.apache.avalon.framework.activity.Initializable; @@ -92,17 +93,26 @@ * * AggregatedValidity is handled recursively. */ - public void store(PipelineCacheKey key, + public void store(Serializable key, CachedResponse response) throws ProcessingException { SourceValidity[] validities = response.getValidityObjects(); for (int i=0; i< validities.length;i++) { SourceValidity val = validities[i]; - examineValidity(val, key); + examineValidity(val, key); } - super.store(key, response); + super.store(key, response); } + /* (non-Javadoc) + * @see org.apache.cocoon.caching.Cache#store(java.io.Serializable, org.apache.cocoon.caching.CachedResponse) + + public void store(Serializable key, CachedResponse response) + throws ProcessingException { + // TODO Auto-generated method stub + super.store(key, response); + }*/ + /** * Look up the EventRegistry */ @@ -129,19 +139,19 @@ */ public void processEvent(Event e) { if (e == null) return; - PipelineCacheKey[] pcks = m_eventRegistry.keysForEvent(e); - if (pcks == null) return; - for (int i=0;i + + @@ -35,6 +37,7 @@ + 1.3 +1 -1 cocoon-2.1/src/blocks/eventcache/samples/event.js Index: event.js =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/eventcache/samples/event.js,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- event.js 21 Jul 2003 01:54:37 -0000 1.2 +++ event.js 2 Oct 2003 04:21:17 -0000 1.3 @@ -1,4 +1,4 @@ -var role = Packages.org.apache.cocoon.caching.Cache.ROLE; +var role = Packages.org.apache.cocoon.caching.Cache.ROLE + "/EventAware"; function cacheEvent() { var cache = cocoon.getComponent(role); 1.2 +5 -4 cocoon-2.1/src/blocks/eventcache/samples/eventcache.xsp Index: eventcache.xsp =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/eventcache/samples/eventcache.xsp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- eventcache.xsp 14 Jul 2003 02:50:45 -0000 1.1 +++ eventcache.xsp 2 Oct 2003 04:21:17 -0000 1.2 @@ -3,7 +3,7 @@ @@ -100,10 +100,10 @@ Test links: @@ -127,7 +127,8 @@ the EventAware cache implementation is that it allows other components to contact it and notify it of an Event. The Cache then looks up the keys mapped to that event in the event registry and cleans out the cache and - registry accordingly. + registry accordingly. See the sitemap of this sample for an example of + configuring a pipeline to use this implementation.
  • The EventRegistry is responsible for mapping Events to cache keys, and providing information about that mapping to systems that need it, usually just the EventAwareCache. Another crucial responsibility of the EventRegistry is to 1.3 +7 -5 cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/EventRegistry.java Index: EventRegistry.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/eventcache/java/org/apache/cocoon/caching/EventRegistry.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- EventRegistry.java 20 Jul 2003 21:08:06 -0000 1.2 +++ EventRegistry.java 2 Oct 2003 04:21:17 -0000 1.3 @@ -50,6 +50,8 @@ */ package org.apache.cocoon.caching; +import java.io.Serializable; + import org.apache.avalon.framework.component.Component; import org.apache.cocoon.caching.validity.Event; @@ -76,14 +78,14 @@ * @param event * @param key */ - public void register(Event e, PipelineCacheKey key); + public void register(Event e, Serializable key); /** * Remove all occurances of the specified key from the registry. * * @param key - The key to remove. */ - public void removeKey(PipelineCacheKey key); + public void removeKey(Serializable key); /** * Retrieve an array of all keys mapped to this event. @@ -92,7 +94,7 @@ * @return an array of keys which should not be modified or null if * no keys are mapped to this event. */ - public PipelineCacheKey[] keysForEvent(Event e); + public Serializable[] keysForEvent(Event e); /** * Retrieve an array of all keys regardless of event mapping, or null if @@ -100,7 +102,7 @@ * * @return an array of keys which should not be modified */ - public PipelineCacheKey[] allKeys(); + public Serializable[] allKeys(); /** * Clear all event-key mappings from the registry.