1 16 package org.apache.cocoon.acting; 17 18 import org.apache.avalon.framework.parameters.Parameters; 19 import org.apache.avalon.framework.thread.ThreadSafe; 20 import org.apache.cocoon.caching.Cache; 21 import org.apache.cocoon.environment.Redirector; 22 import org.apache.cocoon.environment.SourceResolver; 23 24 import java.util.Map ; 25 26 33 public class ClearCacheAction extends ServiceableAction implements ThreadSafe { 34 35 public Map act(Redirector redirector, 36 SourceResolver resolver, 37 Map objectModel, 38 String src, 39 Parameters par 40 ) throws Exception { 41 final String cacheRole = par.getParameter("cache-role", Cache.ROLE); 42 Cache cache = null; 43 44 try { 45 cache = (Cache)this.manager.lookup(cacheRole); 46 cache.clear(); 47 return EMPTY_MAP; 48 } catch (Exception ex) { 49 if (this.getLogger().isDebugEnabled()) { 50 getLogger().debug("Exception while trying to clear Cache with role " + cacheRole, ex); 51 } 52 return null; 53 } finally { 54 this.manager.release( cache ); 55 } 56 } 57 } 58 | Popular Tags |