cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect RendererAspect.java
Date Sat, 14 Jun 2003 17:55:44 GMT
cziegeler    2003/06/14 10:55:44

  Modified:    src/blocks/portal/java/org/apache/cocoon/portal/layout/impl
                        DefaultLayoutFactory.java
               src/blocks/portal/java/org/apache/cocoon/portal/coplet/impl
                        DefaultCopletFactory.java
               src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/impl
                        AspectRenderer.java AbstractRenderer.java
               src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl
                        RendererAspectChain.java XSLTAspect.java
                        TabContentAspect.java AbstractAspect.java
               src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl
                        DefaultAspectDescription.java
               src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer
                        Renderer.java
               src/blocks/portal/conf portal.xconf
               src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect
                        RendererAspect.java
  Log:
  Simplifying configuration: aspect renderers can add their own descriptions
  
  Revision  Changes    Path
  1.12      +83 -47    cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java
  
  Index: DefaultLayoutFactory.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultLayoutFactory.java	14 Jun 2003 16:58:02 -0000	1.11
  +++ DefaultLayoutFactory.java	14 Jun 2003 17:55:43 -0000	1.12
  @@ -72,6 +72,7 @@
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.portal.aspect.AspectDataHandler;
   import org.apache.cocoon.portal.aspect.AspectDataStore;
  +import org.apache.cocoon.portal.aspect.AspectDescription;
   import org.apache.cocoon.portal.aspect.impl.DefaultAspectDataHandler;
   import org.apache.cocoon.portal.aspect.impl.DefaultAspectDescription;
   import org.apache.cocoon.portal.coplet.CopletFactory;
  @@ -85,6 +86,7 @@
   import org.apache.cocoon.portal.layout.Item;
   import org.apache.cocoon.portal.layout.Layout;
   import org.apache.cocoon.portal.layout.LayoutFactory;
  +import org.apache.cocoon.portal.layout.renderer.Renderer;
   import org.apache.cocoon.portal.profile.ProfileManager;
   import org.apache.cocoon.util.ClassUtils;
   
  @@ -114,61 +116,95 @@
       
       protected ComponentManager manager;
       
  -    /* (non-Javadoc)
  -     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
  +    /** 
  +     * Configure a layout
        */
  -    public void configure(Configuration configuration) 
  +    protected void configureLayout(Configuration layoutConf) 
       throws ConfigurationException {
  -        final Configuration[] layoutsConf = configuration.getChild("layouts").getChildren("layout");
  -        if ( layoutsConf != null ) {
  -            for(int i=0; i < layoutsConf.length; i++ ) {
  -                DefaultLayoutDescription desc = new DefaultLayoutDescription();
  -                final String name = layoutsConf[i].getAttribute("name");
  +        DefaultLayoutDescription desc = new DefaultLayoutDescription();
  +        final String name = layoutConf.getAttribute("name");
                   
  -                // unique test
  -                if ( this.layouts.get(name) != null) {
  -                    throw new ConfigurationException("Layout name must be unique. Double
definition for " + name);
  -                }
  -                desc.setName(name);
  -                desc.setClassName(layoutsConf[i].getAttribute("class"));        
  -                desc.setCreateId(layoutsConf[i].getAttributeAsBoolean("create-id", false));
  +        // unique test
  +        if ( this.layouts.get(name) != null) {
  +            throw new ConfigurationException("Layout name must be unique. Double definition
for " + name);
  +        }
  +        desc.setName(name);
  +        desc.setClassName(layoutConf.getAttribute("class"));        
  +        desc.setCreateId(layoutConf.getAttributeAsBoolean("create-id", false));
                   
  -                // the renderers
  -                final String defaultRenderer = layoutsConf[i].getChild("renderers").getAttribute("default");
  -                desc.setDefaultRendererName(defaultRenderer); 
  +        // the renderers
  +        final String defaultRenderer = layoutConf.getChild("renderers").getAttribute("default");
  +        desc.setDefaultRendererName(defaultRenderer); 
                                   
  -                final Configuration[] rendererConfs = layoutsConf[i].getChild("renderers").getChildren("renderer");
  -                if ( rendererConfs != null ) {
  -                    boolean found = false;
  -                    for(int m=0; m < rendererConfs.length; m++) {
  -                        final String rName = rendererConfs[m].getAttribute("name");
  -                        desc.addRendererName(rName);
  -                        if ( defaultRenderer.equals(rName) ) {
  -                            found = true;
  -                        }
  -                    }
  -                    if ( !found ) {
  -                        throw new ConfigurationException("Default renderer '" + defaultRenderer
+ "' is not configured for layout '" + name + "'");
  -                    }
  -                } else {
  -                    throw new ConfigurationException("Default renderer '" + defaultRenderer
+ "' is not configured for layout '" + name + "'");
  +        final Configuration[] rendererConfs = layoutConf.getChild("renderers").getChildren("renderer");
  +        if ( rendererConfs != null ) {
  +            boolean found = false;
  +            for(int m=0; m < rendererConfs.length; m++) {
  +                final String rName = rendererConfs[m].getAttribute("name");
  +                desc.addRendererName(rName);
  +                if ( defaultRenderer.equals(rName) ) {
  +                    found = true;
                   }
  -                // and now the aspects
  -                final Configuration[] aspectsConf = layoutsConf[i].getChild("aspects").getChildren("aspect");
  -                if (aspectsConf != null) {
  -                    for(int m=0; m < aspectsConf.length; m++) {
  -                        DefaultAspectDescription adesc = new DefaultAspectDescription();
  -                        adesc.setClassName(aspectsConf[m].getAttribute("class"));
  -                        adesc.setName(aspectsConf[m].getAttribute("name"));
  -                        adesc.setPersistence(aspectsConf[m].getAttribute("store"));
  -                        adesc.setAutoCreate(aspectsConf[m].getAttributeAsBoolean("auto-create",
false));
  -                        adesc.setDefaultValue(aspectsConf[m].getAttribute("value", null));
  +            }
  +            if ( !found ) {
  +                throw new ConfigurationException("Default renderer '" + defaultRenderer
+ "' is not configured for layout '" + name + "'");
  +            }
  +        } else {
  +            throw new ConfigurationException("Default renderer '" + defaultRenderer + "'
is not configured for layout '" + name + "'");
  +        }
  +        
  +        // and now the aspects
  +        final Configuration[] aspectsConf = layoutConf.getChild("aspects").getChildren("aspect");
  +        if (aspectsConf != null) {
  +            for(int m=0; m < aspectsConf.length; m++) {
  +                AspectDescription adesc = DefaultAspectDescription.newInstance(aspectsConf[m]);
  +                desc.addAspectDescription( adesc );
  +            }
  +        }
  +        // now query all configured renderers for their aspects
  +        ComponentSelector rendererSelector = null;
  +        try {
  +            rendererSelector = (ComponentSelector)this.manager.lookup(Renderer.ROLE+"Selector");
  +            
  +            Iterator rendererIterator = desc.getRendererNames();
  +            while (rendererIterator.hasNext()) {
  +                final String rendererName = (String)rendererIterator.next();
  +                Renderer renderer = null;
  +                try { 
  +                    renderer = (Renderer) rendererSelector.select( rendererName );
  +                    
  +                    Iterator aspectIterator = renderer.getAspectDescriptions();
  +                    while (aspectIterator.hasNext()) {
  +                        final AspectDescription adesc = (AspectDescription) aspectIterator.next();
                           desc.addAspectDescription( adesc );
                       }
  +                } catch (ComponentException ce ) {
  +                    throw new ConfigurationException("Unable to lookup renderer '" + rendererName
+ "'", ce);
  +                } finally {
  +                    rendererSelector.release( renderer );
                   }
  -                DefaultAspectDataHandler handler = new DefaultAspectDataHandler(desc, this.storeSelector);
  -                this.layouts.put(desc.getName(), new Object[] {desc, handler});
  -                this.descriptions.add(desc);
  +            }
  +        } catch (ComponentException ce ) {
  +            throw new ConfigurationException("Unable to lookup renderer selector.", ce);
  +        } finally {
  +            this.manager.release( rendererSelector );
  +        }
  +        
  +        // set the aspect data handler
  +        DefaultAspectDataHandler handler = new DefaultAspectDataHandler(desc, this.storeSelector);
  +        this.layouts.put(desc.getName(), new Object[] {desc, handler});
  +        this.descriptions.add(desc);
  +    }
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
  +     */
  +    public void configure(Configuration configuration) 
  +    throws ConfigurationException {
  +        final Configuration[] layoutsConf = configuration.getChild("layouts").getChildren("layout");
  +        if ( layoutsConf != null ) {
  +            for(int i=0; i < layoutsConf.length; i++ ) {
  +                this.configureLayout( layoutsConf[i] );
               }
           }
       }
  
  
  
  1.6       +4 -14     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/impl/DefaultCopletFactory.java
  
  Index: DefaultCopletFactory.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/impl/DefaultCopletFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultCopletFactory.java	6 Jun 2003 11:33:38 -0000	1.5
  +++ DefaultCopletFactory.java	14 Jun 2003 17:55:43 -0000	1.6
  @@ -69,6 +69,7 @@
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.portal.aspect.AspectDataHandler;
   import org.apache.cocoon.portal.aspect.AspectDataStore;
  +import org.apache.cocoon.portal.aspect.AspectDescription;
   import org.apache.cocoon.portal.aspect.impl.DefaultAspectDataHandler;
   import org.apache.cocoon.portal.aspect.impl.DefaultAspectDescription;
   import org.apache.cocoon.portal.coplet.CopletData;
  @@ -236,12 +237,7 @@
                   Configuration[] aspectsConf = copletsConf[i].getChild("coplet-data-aspects").getChildren("aspect");
                   if (aspectsConf != null) {
                       for(int m=0; m < aspectsConf.length; m++) {
  -                        DefaultAspectDescription adesc = new DefaultAspectDescription();
  -                        adesc.setClassName(aspectsConf[m].getAttribute("class"));
  -                        adesc.setName(aspectsConf[m].getAttribute("name"));
  -                        adesc.setPersistence(aspectsConf[m].getAttribute("store"));
  -                        adesc.setAutoCreate(aspectsConf[m].getAttributeAsBoolean("auto-create",
false));
  -                        adesc.setDefaultValue(aspectsConf[m].getAttribute("value", null));
  +                        AspectDescription adesc = DefaultAspectDescription.newInstance(aspectsConf[m]);
                           desc.addAspectDescription( adesc );
                       }
                   }
  @@ -250,13 +246,7 @@
                   aspectsConf = copletsConf[i].getChild("coplet-instance-data-aspects").getChildren("aspect");
                   if (aspectsConf != null) {
                       for(int m=0; m < aspectsConf.length; m++) {
  -                        DefaultAspectDescription adesc = new DefaultAspectDescription();
  -                        adesc.setClassName(aspectsConf[m].getAttribute("class"));
  -                        adesc.setName(aspectsConf[m].getAttribute("name"));
  -                        adesc.setPersistence(aspectsConf[m].getAttribute("store"));
  -                        adesc.setAutoCreate(aspectsConf[m].getAttributeAsBoolean("auto-create",
false));
  -                        adesc.setDefaultValue(aspectsConf[m].getAttribute("value", null));
  -                        desc.addInstanceAspectDescription( adesc );
  +                        AspectDescription adesc = DefaultAspectDescription.newInstance(aspectsConf[m]);
                           instanceDesc.addAspectDescription( adesc );
                       }
                   }
  
  
  
  1.2       +12 -2     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/impl/AspectRenderer.java
  
  Index: AspectRenderer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/impl/AspectRenderer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AspectRenderer.java	7 May 2003 06:22:22 -0000	1.1
  +++ AspectRenderer.java	14 Jun 2003 17:55:43 -0000	1.2
  @@ -50,6 +50,8 @@
   */
   package org.apache.cocoon.portal.layout.renderer.impl;
   
  +import java.util.Iterator;
  +
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.component.ComponentManager;
  @@ -65,7 +67,8 @@
   import org.apache.cocoon.portal.layout.renderer.Renderer;
   import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspect;
   import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext;
  -import org.apache.cocoon.portal.layout.renderer.aspect.impl.*;
  +import org.apache.cocoon.portal.layout.renderer.aspect.impl.DefaultRendererContext;
  +import org.apache.cocoon.portal.layout.renderer.aspect.impl.RendererAspectChain;
   import org.xml.sax.ContentHandler;
   import org.xml.sax.SAXException;
   
  @@ -123,5 +126,12 @@
               this.manager = null;
   		}
   	}
  +
  +    /**
  +     * Return the aspects required for this renderer
  +     */
  +    public Iterator getAspectDescriptions() {
  +        return this.chain.getAspectDescriptionIterator();
  +    }
   
   }
  
  
  
  1.3       +11 -1     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/impl/AbstractRenderer.java
  
  Index: AbstractRenderer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/impl/AbstractRenderer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractRenderer.java	22 May 2003 12:32:47 -0000	1.2
  +++ AbstractRenderer.java	14 Jun 2003 17:55:43 -0000	1.3
  @@ -50,6 +50,9 @@
   */
   package org.apache.cocoon.portal.layout.renderer.impl;
   
  +import java.util.Collections;
  +import java.util.Iterator;
  +
   import javax.xml.transform.sax.SAXResult;
   import javax.xml.transform.sax.TransformerHandler;
   
  @@ -176,5 +179,12 @@
       }
           
       protected abstract void process(Layout layout, PortalService service, ContentHandler
handler) throws SAXException;
  +
  +    /**
  +     * Return the aspects required for this renderer
  +     */
  +    public Iterator getAspectDescriptions() {
  +        return Collections.EMPTY_LIST.iterator();
  +    }
       
   }
  
  
  
  1.2       +23 -6     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/RendererAspectChain.java
  
  Index: RendererAspectChain.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/RendererAspectChain.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RendererAspectChain.java	7 May 2003 06:22:22 -0000	1.1
  +++ RendererAspectChain.java	14 Jun 2003 17:55:43 -0000	1.2
  @@ -60,9 +60,11 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.parameters.Parameters;
  +import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspect;
   
   /**
  - *
  + * This chain holds all configured renderer aspects for one renderer.
  + * 
    * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
    * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
    * 
  @@ -70,9 +72,11 @@
    */
   public final class RendererAspectChain {
       
  -    private List aspects = new ArrayList();
  +    protected List aspects = new ArrayList(3);
  +    
  +    protected List configs = new ArrayList(3);
       
  -    private List configs = new ArrayList();
  +    protected List aspectDescriptions = new ArrayList(2);
       
       public void configure(ComponentSelector selector, Configuration conf) 
       throws ConfigurationException {
  @@ -83,8 +87,17 @@
                       final Configuration current = aspects[i];
                       final String role = current.getAttribute("type");
                       try {
  -                        this.aspects.add(selector.select(role));
  -                        this.configs.add(Parameters.fromConfiguration(current));
  +                        RendererAspect rAspect = (RendererAspect) selector.select(role);
  +                        Parameters aspectConfiguration = Parameters.fromConfiguration(current);
  +                        this.aspects.add(rAspect);               
  +                        this.configs.add(aspectConfiguration);
  +                        
  +                        Iterator descriptionIterator = rAspect.getAspectDescriptions(aspectConfiguration);
  +                        if ( descriptionIterator != null ) {
  +                            while ( descriptionIterator.hasNext() ) {
  +                                this.aspectDescriptions.add( descriptionIterator.next()
);
  +                            }
  +                        }
                       } catch (ComponentException se) {
                           throw new ConfigurationException("Unable to lookup aspect " + role,
se);
                       }
  @@ -101,6 +114,10 @@
       
       public Iterator getConfigIterator() {
           return this.configs.iterator();
  +    }
  +    
  +    public Iterator getAspectDescriptionIterator() {
  +        return this.aspectDescriptions.iterator();
       }
       
       public void dispose(ComponentSelector selector) {
  
  
  
  1.4       +2 -16     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java
  
  Index: XSLTAspect.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XSLTAspect.java	10 Jun 2003 19:38:54 -0000	1.3
  +++ XSLTAspect.java	14 Jun 2003 17:55:43 -0000	1.4
  @@ -57,15 +57,10 @@
   
   import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.avalon.framework.component.Composable;
  -import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.cocoon.components.variables.VariableResolver;
   import org.apache.cocoon.components.variables.VariableResolverFactory;
   import org.apache.cocoon.portal.PortalService;
   import org.apache.cocoon.portal.layout.Layout;
  -import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspect;
   import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext;
   import org.apache.cocoon.xml.IncludeXMLConsumer;
   import org.apache.excalibur.source.Source;
  @@ -85,11 +80,8 @@
    * @version CVS $Id$
    */
   public class XSLTAspect 
  -    extends AbstractLogEnabled 
  -    implements RendererAspect, ThreadSafe, Composable {
  +    extends AbstractAspect {
   
  -    protected ComponentManager manager;
  -    
   	/* (non-Javadoc)
   	 * @see org.apache.cocoon.portal.layout.renderer.RendererAspect#toSAX(org.apache.cocoon.portal.layout.renderer.RendererAspectContext,
org.apache.cocoon.portal.layout.Layout, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler)
   	 */
  @@ -150,11 +142,5 @@
           }
           return stylesheet;
       }
  -	/* (non-Javadoc)
  -	 * @see org.apache.avalon.framework.component.Composable#compose(org.apache.avalon.framework.component.ComponentManager)
  -	 */
  -	public void compose(ComponentManager manager) throws ComponentException {
  -        this.manager = manager;
  -	}
   
   }
  
  
  
  1.7       +19 -2     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/TabContentAspect.java
  
  Index: TabContentAspect.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/TabContentAspect.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TabContentAspect.java	23 May 2003 14:20:09 -0000	1.6
  +++ TabContentAspect.java	14 Jun 2003 17:55:43 -0000	1.7
  @@ -50,11 +50,14 @@
   */
   package org.apache.cocoon.portal.layout.renderer.aspect.impl;
   
  +import java.util.Collections;
   import java.util.Iterator;
   import java.util.Map;
   
   import org.apache.avalon.framework.component.ComponentException;
  +import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.portal.PortalService;
  +import org.apache.cocoon.portal.aspect.impl.DefaultAspectDescription;
   import org.apache.cocoon.portal.event.impl.ChangeAspectDataEvent;
   import org.apache.cocoon.portal.layout.CompositeLayout;
   import org.apache.cocoon.portal.layout.Layout;
  @@ -99,7 +102,7 @@
                   CompositeLayout tabLayout = (CompositeLayout) layout;
   
                   // selected tab
  -                Integer data = (Integer) layout.getAspectData("tab");
  +                Integer data = (Integer) layout.getAspectData(context.getAspectParameters().getParameter("aspect-name",
"tab"));
                   int selected = data.intValue();
                   
                   // loop over all tabs
  @@ -133,6 +136,20 @@
           }
   
   
  +    }
  +
  +    /**
  +     * Return the aspects required for this renderer
  +     * @return An iterator for the aspect descriptions or null.
  +     */
  +    public Iterator getAspectDescriptions(Parameters configuration) {
  +        DefaultAspectDescription desc = new DefaultAspectDescription();
  +        desc.setName(configuration.getParameter("aspect-name", "tab"));
  +        desc.setClassName("java.lang.Integer");
  +        desc.setPersistence(configuration.getParameter("store", "session"));
  +        desc.setAutoCreate(true);
  +        
  +        return Collections.singletonList(desc).iterator();
       }
   
   }
  
  
  
  1.3       +12 -1     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/AbstractAspect.java
  
  Index: AbstractAspect.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/AbstractAspect.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractAspect.java	22 May 2003 12:32:46 -0000	1.2
  +++ AbstractAspect.java	14 Jun 2003 17:55:43 -0000	1.3
  @@ -50,10 +50,13 @@
   */
   package org.apache.cocoon.portal.layout.renderer.aspect.impl;
   
  +import java.util.Iterator;
  +
   import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspect;
   
  @@ -75,6 +78,14 @@
        */
       public void compose(ComponentManager componentManager) throws ComponentException {
           this.manager = componentManager;
  +    }
  +
  +    /**
  +     * Return the aspects required for this renderer
  +     * @return An iterator for the aspect descriptions or null.
  +     */
  +    public Iterator getAspectDescriptions(Parameters configuration) {
  +        return null;
       }
   
   }
  
  
  
  1.3       +27 -1     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/DefaultAspectDescription.java
  
  Index: DefaultAspectDescription.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/DefaultAspectDescription.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultAspectDescription.java	22 May 2003 12:32:47 -0000	1.2
  +++ DefaultAspectDescription.java	14 Jun 2003 17:55:43 -0000	1.3
  @@ -50,6 +50,8 @@
    */
   package org.apache.cocoon.portal.aspect.impl;
   
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.cocoon.portal.aspect.AspectDescription;
   
   
  @@ -75,6 +77,22 @@
       protected String defaultValue;
       
       /**
  +     * Create a new description from a {@link Configuration} object.
  +     * All values must be stored as attributes
  +     */
  +    public static AspectDescription newInstance(Configuration conf)
  +    throws ConfigurationException {
  +        DefaultAspectDescription adesc = new DefaultAspectDescription();
  +        adesc.setClassName(conf.getAttribute("class"));
  +        adesc.setName(conf.getAttribute("name"));
  +        adesc.setPersistence(conf.getAttribute("store"));
  +        adesc.setAutoCreate(conf.getAttributeAsBoolean("auto-create", false));
  +        adesc.setDefaultValue(conf.getAttribute("value", null));
  +        
  +        return adesc;
  +    }
  +    
  +    /**
        * @return
        */
       public String getClassName() {
  @@ -139,5 +157,13 @@
   
       public void setDefaultValue(String value) {
           this.defaultValue = value;
  +    }
  +    
  +    public String toString() {
  +        return ("AspectDescription name=" + this.name + 
  +                 ", class=" + this.className +
  +                 ", persistence=" + this.persistence +
  +                 ", autoCreate=" + this.autoCreate +
  +                 ", defaultValue=" + this.defaultValue);
       }
   }
  
  
  
  1.3       +9 -1      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/Renderer.java
  
  Index: Renderer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/Renderer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Renderer.java	7 May 2003 20:24:03 -0000	1.2
  +++ Renderer.java	14 Jun 2003 17:55:44 -0000	1.3
  @@ -50,6 +50,8 @@
   */
   package org.apache.cocoon.portal.layout.renderer;
   
  +import java.util.Iterator;
  +
   import org.apache.avalon.framework.component.Component;
   import org.apache.cocoon.portal.PortalService;
   import org.apache.cocoon.portal.layout.Layout;
  @@ -75,4 +77,10 @@
       void toSAX(Layout layout, PortalService service, ContentHandler handler)
       throws SAXException;
   
  +    /**
  +     * Return the aspects required for this renderer.
  +     * This method always returns an iterator even if no descriptions are
  +     * available.
  +     */
  +    Iterator getAspectDescriptions();
   }
  
  
  
  1.17      +1 -3      cocoon-2.1/src/blocks/portal/conf/portal.xconf
  
  Index: portal.xconf
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/conf/portal.xconf,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- portal.xconf	14 Jun 2003 16:58:02 -0000	1.16
  +++ portal.xconf	14 Jun 2003 17:55:44 -0000	1.17
  @@ -90,6 +90,7 @@
                </aspect>
                <aspect type="tab-content">
                    <parameter name="tag-name" value="tab-layout"/>
  +                 <parameter name="store"    value="session"/>
                </aspect>
            </aspects>
        </renderer>
  @@ -152,9 +153,6 @@
               <renderers default="tab">
                   <renderer name="tab"/>
               </renderers>
  -            <aspects>
  -                <aspect name="tab" class="java.lang.Integer" store="session" auto-create="true"/>
  -            </aspects>
           </layout>
           <layout name="frame" 
                   class="org.apache.cocoon.portal.layout.impl.FrameLayout"
  
  
  
  1.3       +10 -1     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/RendererAspect.java
  
  Index: RendererAspect.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/RendererAspect.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RendererAspect.java	7 May 2003 20:24:03 -0000	1.2
  +++ RendererAspect.java	14 Jun 2003 17:55:44 -0000	1.3
  @@ -50,7 +50,10 @@
   */
   package org.apache.cocoon.portal.layout.renderer.aspect;
   
  +import java.util.Iterator;
  +
   import org.apache.avalon.framework.component.Component;
  +import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.portal.PortalService;
   import org.apache.cocoon.portal.layout.Layout;
   import org.xml.sax.ContentHandler;
  @@ -77,5 +80,11 @@
                   PortalService service, 
                   ContentHandler handler)
       throws SAXException;
  +
  +    /**
  +     * Return the aspects required for this renderer
  +     * @return An iterator for the aspect descriptions or null.
  +     */
  +    Iterator getAspectDescriptions(Parameters configuration);
   
   }
  
  
  

Mime
View raw message