1 16 package org.apache.cocoon.components.pipeline.impl; 17 18 import org.apache.avalon.framework.activity.Disposable; 19 import org.apache.avalon.framework.component.ComponentException; 20 import org.apache.avalon.framework.parameters.ParameterException; 21 import org.apache.avalon.framework.parameters.Parameters; 22 import org.apache.cocoon.caching.Cache; 23 import org.apache.cocoon.components.pipeline.AbstractProcessingPipeline; 24 import org.apache.cocoon.components.sax.XMLDeserializer; 25 import org.apache.cocoon.components.sax.XMLSerializer; 26 27 36 public abstract class BaseCachingProcessingPipeline extends AbstractProcessingPipeline 37 implements Disposable { 38 39 40 protected Cache cache; 41 42 43 protected XMLDeserializer xmlDeserializer; 44 45 46 protected XMLSerializer xmlSerializer; 47 48 51 public void parameterize(Parameters params) 52 throws ParameterException { 53 super.parameterize(params); 54 55 String cacheRole = params.getParameter("cache-role", Cache.ROLE); 56 if (getLogger().isDebugEnabled()) { 57 getLogger().debug("Using cache " + cacheRole); 58 } 59 60 try { 61 this.cache = (Cache) this.manager.lookup(cacheRole); 62 } catch (ComponentException ce) { 63 throw new ParameterException("Unable to lookup cache: " + cacheRole, ce); 64 } 65 } 66 67 70 public void recycle() { 71 this.manager.release(this.xmlDeserializer); 72 this.xmlDeserializer = null; 73 74 this.manager.release(this.xmlSerializer); 75 this.xmlSerializer = null; 76 77 super.recycle(); 78 } 79 80 83 public void dispose() { 84 if (null != this.manager) { 85 this.manager.release(this.cache); 86 } 87 this.cache = null; 88 this.manager = null; 89 } 90 } 91 | Popular Tags |