1 16 package org.apache.cocoon.portal.layout.renderer.impl; 17 18 import java.util.Iterator ; 19 20 import org.apache.avalon.framework.activity.Disposable; 21 import org.apache.avalon.framework.configuration.Configurable; 22 import org.apache.avalon.framework.configuration.Configuration; 23 import org.apache.avalon.framework.configuration.ConfigurationException; 24 import org.apache.avalon.framework.context.Context; 25 import org.apache.avalon.framework.context.ContextException; 26 import org.apache.avalon.framework.context.Contextualizable; 27 import org.apache.avalon.framework.logger.AbstractLogEnabled; 28 import org.apache.avalon.framework.service.ServiceException; 29 import org.apache.avalon.framework.service.ServiceManager; 30 import org.apache.avalon.framework.service.ServiceSelector; 31 import org.apache.avalon.framework.service.Serviceable; 32 import org.apache.avalon.framework.thread.ThreadSafe; 33 import org.apache.cocoon.components.ContextHelper; 34 import org.apache.cocoon.portal.PortalService; 35 import org.apache.cocoon.portal.layout.Layout; 36 import org.apache.cocoon.portal.layout.renderer.Renderer; 37 import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspect; 38 import org.apache.cocoon.portal.layout.renderer.aspect.impl.DefaultRendererContext; 39 import org.apache.cocoon.portal.layout.renderer.aspect.impl.RendererAspectChain; 40 import org.xml.sax.ContentHandler ; 41 import org.xml.sax.SAXException ; 42 43 59 public class AspectRenderer 60 extends AbstractLogEnabled 61 implements Renderer, Serviceable, Configurable, Disposable, ThreadSafe, Contextualizable { 62 63 protected ServiceManager manager; 64 65 protected RendererAspectChain chain; 66 67 protected ServiceSelector aspectSelector; 68 69 protected Context context; 70 71 74 public void service(ServiceManager manager) throws ServiceException { 75 this.manager = manager; 76 this.aspectSelector = (ServiceSelector) this.manager.lookup( RendererAspect.ROLE+"Selector"); 77 } 78 79 82 public void toSAX(Layout layout, PortalService service, ContentHandler handler) throws SAXException { 83 Boolean isRenderable = service.isRenderable(); 84 DefaultRendererContext renderContext = new DefaultRendererContext(this.chain, layout, service); 85 renderContext.setObjectModel(ContextHelper.getObjectModel(this.context)); 86 renderContext.invokeNext(layout, service, handler); 87 service.setRenderable(isRenderable); 88 } 89 90 93 public void configure(Configuration conf) throws ConfigurationException { 94 this.chain = new RendererAspectChain(); 95 this.chain.configure(this.aspectSelector, conf.getChild("aspects")); 96 } 97 98 101 public void dispose() { 102 if (this.manager != null) { 103 if ( this.chain != null) { 104 this.chain.dispose( this.aspectSelector ); 105 } 106 this.manager.release( this.aspectSelector ); 107 this.aspectSelector = null; 108 this.manager = null; 109 } 110 } 111 112 115 public Iterator getAspectDescriptions() { 116 return this.chain.getAspectDescriptionIterator(); 117 } 118 119 122 public void contextualize(Context context) throws ContextException { 123 this.context = context; 124 } 125 126 } 127 | Popular Tags |