cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: rev 55961 - in cocoon/branches/BRANCH_2_1_X/src/blocks/portal: conf java/org/apache/cocoon/portal/coplet/impl java/org/apache/cocoon/portal/layout java/org/apache/cocoon/portal/layout/impl
Date Fri, 29 Oct 2004 10:09:03 GMT
Author: cziegeler
Date: Fri Oct 29 03:09:02 2004
New Revision: 55961

Removed:
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/TabbedLayoutImpl.java
Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/conf/portal.samplesxconf
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/impl/DefaultCopletFactory.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/CompositeLayout.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/LayoutDescription.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/CompositeLayoutImpl.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutDescription.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java
Log:
Implementation of Items are now configurable. Improved id creation for coplets and layouts

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/conf/portal.samplesxconf
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/conf/portal.samplesxconf	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/conf/portal.samplesxconf	Fri Oct 29 03:09:02
2004
@@ -182,19 +182,22 @@
             </renderers>
         </layout>
         <layout name="tab" 
-                class="org.apache.cocoon.portal.layout.impl.TabbedLayoutImpl">
+                class="org.apache.cocoon.portal.layout.impl.CompositeLayoutImpl"
+                item-class="org.apache.cocoon.portal.layout.NamedItem">
             <renderers default="tab">
                 <renderer name="tab"/>
             </renderers>
         </layout>
         <layout name="rawtab" 
-                class="org.apache.cocoon.portal.layout.impl.TabbedLayoutImpl">
+                class="org.apache.cocoon.portal.layout.impl.CompositeLayoutImpl"
+                item-class="org.apache.cocoon.portal.layout.NamedItem">
             <renderers default="rawtab">
                 <renderer name="rawtab"/>
             </renderers>
         </layout>
         <layout name="linktab"
-                class="org.apache.cocoon.portal.layout.impl.TabbedLayoutImpl" >
+                class="org.apache.cocoon.portal.layout.impl.CompositeLayoutImpl"
+                item-class="org.apache.cocoon.portal.layout.NamedItem">
             <renderers default="linktab">
                 <renderer name="linktab"/>
             </renderers>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/impl/DefaultCopletFactory.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/impl/DefaultCopletFactory.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/impl/DefaultCopletFactory.java
Fri Oct 29 03:09:02 2004
@@ -62,6 +62,8 @@
     
     protected ServiceSelector storeSelector;
 
+    protected static long idCounter = System.currentTimeMillis();
+	
     /* (non-Javadoc)
      * @see org.apache.cocoon.portal.coplet.CopletFactory#prepare(org.apache.cocoon.portal.coplet.CopletData)
      */
@@ -128,8 +130,10 @@
         
         String id = null;
         if ( copletDescription.createId() ) {
-            // TODO - create unique id
-            id = name + '-' + System.currentTimeMillis();
+            synchronized (this) {
+                id = copletData.getId() + '-' + idCounter;
+                idCounter += 1;
+            }
         }
         instance.initialize( name, id );
         

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/CompositeLayout.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/CompositeLayout.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/CompositeLayout.java
Fri Oct 29 03:09:02 2004
@@ -73,4 +73,14 @@
      */
     Item createNewItem();
     
+    /**
+     * @return Returns the item class name.
+     */
+    String getItemClassName();
+    
+    /**
+     * @param itemClassName The item class name to set.
+     */
+    void setItemClassName(String value);
+    
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/LayoutDescription.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/LayoutDescription.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/LayoutDescription.java
Fri Oct 29 03:09:02 2004
@@ -19,14 +19,12 @@
 
 import org.apache.cocoon.portal.factory.ProducibleDescription;
 
-
-
 /**
  * A configured layout
  * 
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
  * 
- * @version CVS $Id: LayoutDescription.java,v 1.4 2004/03/05 13:02:13 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public interface LayoutDescription
     extends ProducibleDescription  {
@@ -40,4 +38,9 @@
      * @return the names of all allowed renderers
      */
     Iterator getRendererNames();
+    
+    /**
+     * @return The class name of the item
+     */
+    String getItemClassName();
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/CompositeLayoutImpl.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/CompositeLayoutImpl.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/CompositeLayoutImpl.java
Fri Oct 29 03:09:02 2004
@@ -23,6 +23,7 @@
 import org.apache.cocoon.portal.layout.CompositeLayout;
 import org.apache.cocoon.portal.layout.Item;
 import org.apache.cocoon.portal.layout.Layout;
+import org.apache.cocoon.util.ClassUtils;
 
 
 /**
@@ -37,8 +38,11 @@
     extends AbstractLayout
     implements CompositeLayout {
 
-	protected List items = new ArrayList();
+    protected List items = new ArrayList();
 
+    /** The class name of the items */
+    protected String itemClassName;
+    
     /**
      * Constructor
      */
@@ -98,7 +102,28 @@
      * @see org.apache.cocoon.portal.layout.CompositeLayout#createNewItem()
      */
     public Item createNewItem() {
+        if ( this.itemClassName == null ) {
         return new Item();
+    }
+        try {
+            return (Item)ClassUtils.newInstance(this.itemClassName);
+        } catch (Exception ignore) {
+            return new Item();
+        }
+    }
+        
+    /**
+     * @return Returns the item class name.
+     */
+    public String getItemClassName() {
+        return this.itemClassName;
+    }
+    
+    /**
+     * @param itemClassName The item class name to set.
+     */
+    public void setItemClassName(String value) {
+        this.itemClassName = value;
     }
         
     /* (non-Javadoc)

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutDescription.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutDescription.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutDescription.java
Fri Oct 29 03:09:02 2004
@@ -28,7 +28,7 @@
  * 
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
  * 
- * @version CVS $Id: DefaultLayoutDescription.java,v 1.5 2004/03/05 13:02:13 bdelacretaz
Exp $
+ * @version CVS $Id$
  */
 public class DefaultLayoutDescription
     extends AbstractProducibleDescription
@@ -38,6 +38,8 @@
     
     protected List rendererNames = new ArrayList(2);
     
+    protected String itemClassName;
+    
     public String getDefaultRendererName() {
         return defaultRendererName;
     }
@@ -58,5 +60,18 @@
 
     public void addRendererName(String name) {
         this.rendererNames.add( name );
+    }
+    
+    /**
+     * @return Returns the itemClassName.
+     */
+    public String getItemClassName() {
+        return this.itemClassName;
+    }
+    /**
+     * @param itemClassName The itemClassName to set.
+     */
+    public void setItemClassName(String itemClassName) {
+        this.itemClassName = itemClassName;
     }
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java
Fri Oct 29 03:09:02 2004
@@ -146,6 +146,8 @@
     
     protected Configuration[] layoutsConf;
     
+    protected static long idCounter = System.currentTimeMillis();
+
     /* (non-Javadoc)
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
@@ -169,6 +171,7 @@
         desc.setName(name);
         desc.setClassName(layoutConf.getAttribute("class"));        
         desc.setCreateId(layoutConf.getAttributeAsBoolean("create-id", false));
+        desc.setItemClassName(layoutConf.getAttribute("item-class", null));
                 
         // the renderers
         final String defaultRenderer = layoutConf.getChild("renderers").getAttribute("default");
@@ -255,6 +258,9 @@
         }
     }
     
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.layout.LayoutFactory#prepareLayout(org.apache.cocoon.portal.layout.Layout)
+     */
     public void prepareLayout(Layout layout) 
     throws ProcessingException {
         if ( layout != null ) {
@@ -278,6 +284,8 @@
             // recursive
             if ( layout instanceof CompositeLayout ) {
                 CompositeLayout composite = (CompositeLayout)layout;
+                composite.setItemClassName(layoutDescription.getItemClassName());
+                
                 Iterator items = composite.getItems().iterator();
                 while ( items.hasNext() ) {
                     this.prepareLayout( ((Item)items.next()).getLayout() );
@@ -311,13 +319,20 @@
         
         String id = null;
         if ( layoutDescription.createId() ) {
-            // TODO - set unique id
-            id = layoutName + '-' + System.currentTimeMillis();
+            synchronized (this) {
+                id = layoutName + '-' + idCounter;
+                idCounter += 1;
+            }
         }
         layout.initialize( layoutName, id ); 
         layout.setDescription( layoutDescription );
         layout.setAspectDataHandler((AspectDataHandler)o[1]);
 
+        if ( layout instanceof CompositeLayout ) {
+            CompositeLayout composite = (CompositeLayout)layout;
+            composite.setItemClassName(layoutDescription.getItemClassName());
+        }
+        
         PortalService service = null;
         try {
             service = (PortalService)this.manager.lookup(PortalService.ROLE);
@@ -330,6 +345,9 @@
         return layout;
     }
     
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.layout.LayoutFactory#getLayoutDescriptions()
+     */
     public List getLayoutDescriptions() {
         this.init();
         return this.descriptions;

Mime
View raw message