cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r599636 - in /cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal: om/ services/ services/impl/ spring/
Date Thu, 29 Nov 2007 23:36:16 GMT
Author: cziegeler
Date: Thu Nov 29 15:35:52 2007
New Revision: 599636

URL: http://svn.apache.org/viewvc?rev=599636&view=rev
Log:
Correct method names and move create item to layout type.

Removed:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/LayoutDescription.java
Modified:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LayoutType.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LayoutFactory.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLayoutFactory.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/LayoutTypeDefinitionParser.java

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LayoutType.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LayoutType.java?rev=599636&r1=599635&r2=599636&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LayoutType.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LayoutType.java
Thu Nov 29 15:35:52 2007
@@ -21,6 +21,7 @@
 import java.util.List;
 
 import org.apache.cocoon.portal.layout.renderer.Renderer;
+import org.apache.cocoon.util.ClassUtils;
 
 
 /**
@@ -35,7 +36,7 @@
 public class LayoutType {
 
     /** The class name of the layout object. */
-    protected String className;
+    protected String layoutClassName;
 
     /** Should an ID be generated for this layout object. */
     protected boolean createId = false;
@@ -92,15 +93,15 @@
      * The name of the implementation class for this layout object.
      * @return The class name.
      */
-    public String getClassName() {
-        return className;
+    public String getLayoutClassName() {
+        return this.layoutClassName;
     }
 
     /**
      * @param string
      */
-    public void setClassName(String string) {
-        className = string;
+    public void setLayoutClassName(String string) {
+        this.layoutClassName = string;
     }
 
     /**
@@ -131,5 +132,28 @@
      */
     public String getId() {
         return this.id;
+    }
+
+    /**
+     * Create a new item which can be used with all layout objects of this type.
+     */
+    public Item createItem()
+    throws LayoutException {
+        if ( this.itemClassName == null ) {
+            return new Item();
+        }
+        try {
+            return (Item) ClassUtils.newInstance( this.itemClassName );
+        } catch (Exception e ) {
+            throw new LayoutException("Unable to create new item for layout type " + this
+ " of class" + this.itemClassName, e);
+        }
+    }
+
+    /**
+     * @see java.lang.Object#toString()
+     */
+    public String toString() {
+        return "LayoutType (" + this.hashCode() +
+               "), id=" + this.getId() + ", layout-class=" + this.getLayoutClassName();
     }
 }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LayoutFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LayoutFactory.java?rev=599636&r1=599635&r2=599636&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LayoutFactory.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LayoutFactory.java
Thu Nov 29 15:35:52 2007
@@ -18,7 +18,6 @@
 
 import java.util.Collection;
 
-import org.apache.cocoon.portal.om.Item;
 import org.apache.cocoon.portal.om.Layout;
 import org.apache.cocoon.portal.om.LayoutException;
 import org.apache.cocoon.portal.om.LayoutInstance;
@@ -65,11 +64,4 @@
      * the profile manager.
      */
     void remove(Layout layout);
-
-    /**
-     * Create a new item for the layout.
-     * This item is *not* added to the layout.
-     * TODO - We could move this to the layout
-     */
-    Item createItem(Layout layout) throws LayoutException;
 }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLayoutFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLayoutFactory.java?rev=599636&r1=599635&r2=599636&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLayoutFactory.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLayoutFactory.java
Thu Nov 29 15:35:52 2007
@@ -90,9 +90,10 @@
         }
         Layout layout = null;
         try {
-            Class clazz = ClassUtils.loadClass( layoutType.getClassName() );
-            Constructor constructor = clazz.getConstructor(new Class[] {String.class, String.class});
-            layout = (Layout)constructor.newInstance(new Object[] {layoutId, layoutType});
+            Class clazz = ClassUtils.loadClass( layoutType.getLayoutClassName() );
+            Constructor constructor = clazz.getConstructor(new Class[] {String.class});
+            layout = (Layout)constructor.newInstance(new Object[] {layoutId});
+            layout.setLayoutType(layoutType);
         } catch (Exception e) {
             throw new LayoutException("Unable to create new layout instance for: " + layoutType
, e );
         }
@@ -150,21 +151,6 @@
      */
     public Collection getLayoutTypes() {
         return this.layoutTypes.values();
-    }
-
-    /**
-     * @see org.apache.cocoon.portal.services.LayoutFactory#createItem(org.apache.cocoon.portal.om.Layout)
-     */
-    public Item createItem(Layout layout)
-    throws LayoutException {
-        if ( layout.getLayoutType().getItemClassName() == null ) {
-            return new Item();
-        }
-        try {
-            return (Item) ClassUtils.newInstance( layout.getLayoutType().getItemClassName());
-        } catch (Exception e ) {
-            throw new LayoutException("Unable to create new item for layout " + layout, e);
-        }
     }
 
     /**

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/LayoutTypeDefinitionParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/LayoutTypeDefinitionParser.java?rev=599636&r1=599635&r2=599636&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/LayoutTypeDefinitionParser.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/LayoutTypeDefinitionParser.java
Thu Nov 29 15:35:52 2007
@@ -42,7 +42,7 @@
         final String layoutTypeId = element.getAttribute("id");
         beanDef.getConstructorArgumentValues().addIndexedArgumentValue(0, layoutTypeId);
 
-        beanDef.getPropertyValues().addPropertyValue("className", element.getAttribute("layoutClass"));
+        beanDef.getPropertyValues().addPropertyValue("layoutClassName", element.getAttribute("layoutClass"));
         if ( this.getAttributeValue(element, "createLayoutId", null) != null ) {
             beanDef.getPropertyValues().addPropertyValue("createId", this.getAttributeValue(element,
"createLayoutId", "false"));
         }



Mime
View raw message