1 16 package org.apache.cocoon.portal.layout.renderer.aspect.impl; 17 18 import java.util.Collections ; 19 import java.util.Iterator ; 20 21 import org.apache.avalon.framework.parameters.ParameterException; 22 import org.apache.avalon.framework.parameters.Parameters; 23 import org.apache.cocoon.portal.PortalService; 24 import org.apache.cocoon.portal.aspect.impl.DefaultAspectDescription; 25 import org.apache.cocoon.portal.layout.Layout; 26 import org.apache.cocoon.portal.layout.impl.FrameLayout; 27 import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext; 28 import org.xml.sax.ContentHandler ; 29 import org.xml.sax.SAXException ; 30 31 55 public class FrameAspect extends AbstractCIncludeAspect { 56 57 public void toSAX(RendererAspectContext context, Layout layout, PortalService service, ContentHandler handler) 58 throws SAXException { 59 PreparedConfiguration config = (PreparedConfiguration)context.getAspectConfiguration(); 60 61 if (!(layout instanceof FrameLayout)) { 62 throw new SAXException ("Wrong layout type, FrameLayout expected: " + layout.getClass().getName()); 63 } 64 65 String source = (String )layout.getAspectData(config.aspectName); 66 if (source == null) { 67 source = ((FrameLayout) layout).getSource(); 68 } 69 70 this.createCInclude(source, handler); 71 } 72 73 protected static class PreparedConfiguration { 74 public String aspectName; 75 public String store; 76 77 public void takeValues(PreparedConfiguration from) { 78 this.aspectName = from.aspectName; 79 this.store = from.store; 80 } 81 } 82 83 86 public Object prepareConfiguration(Parameters configuration) 87 throws ParameterException { 88 PreparedConfiguration pc = new PreparedConfiguration(); 89 pc.aspectName = configuration.getParameter("aspect-name", "frame"); 90 pc.store = configuration.getParameter("store"); 91 return pc; 92 } 93 94 98 public Iterator getAspectDescriptions(Object configuration) { 99 PreparedConfiguration pc = (PreparedConfiguration)configuration; 100 101 DefaultAspectDescription desc = new DefaultAspectDescription(); 102 desc.setName(pc.aspectName); 103 desc.setClassName("java.lang.String"); 104 desc.setPersistence(pc.store); 105 desc.setAutoCreate(false); 106 107 return Collections.singletonList(desc).iterator(); 108 } 109 } 110 | Popular Tags |