1 16 package org.apache.cocoon.acting; 17 18 import java.util.Map ; 19 20 import org.apache.avalon.framework.parameters.Parameters; 21 import org.apache.avalon.framework.thread.ThreadSafe; 22 23 import org.apache.cocoon.caching.Cache; 24 import org.apache.cocoon.caching.impl.EventAwareCacheImpl; 25 import org.apache.cocoon.caching.validity.NamedEvent; 26 import org.apache.cocoon.environment.Redirector; 27 import org.apache.cocoon.environment.SourceResolver; 28 29 41 public class CacheEventAction extends ServiceableAction implements ThreadSafe { 42 43 47 public Map act(Redirector redirector, 48 SourceResolver resolver, 49 Map objectModel, 50 String src, 51 Parameters par 52 ) throws Exception { 53 final String cacheRole = par.getParameter("cache-role", Cache.ROLE + "/EventAware"); 54 Cache cache = (Cache)this.manager.lookup(cacheRole); 55 try { 56 if (cache instanceof EventAwareCacheImpl) { 58 String eventName = par.getParameter("event"); 59 if (getLogger().isDebugEnabled()) { 60 getLogger().debug("Configured for cache event named: " + eventName); 61 } 62 if (eventName == null || "".equals(eventName)) { 63 return null; 64 } 65 ((EventAwareCacheImpl)cache).processEvent( 66 new NamedEvent(eventName)); 67 } 68 } finally { 69 this.manager.release(cache); 70 } 71 return EMPTY_MAP; 72 } 73 } | Popular Tags |