cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r598833 - in /cocoon/trunk/blocks/cocoon-portal: cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/ cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/util/ cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/ c...
Date Wed, 28 Nov 2007 00:40:37 GMT
Author: cziegeler
Date: Tue Nov 27 16:40:36 2007
New Revision: 598833

URL: http://svn.apache.org/viewvc?rev=598833&view=rev
Log:
Create bean describing a layout type to OM.
Start using bean maps for layout and coplet types.
Fix Avalon configuration for layouts.

Added:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LayoutType.java
  (with props)
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/layout-types.xml
  (with props)
Modified:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/util/HtmlSaxParser.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/avalon/cocoon-portal-sample.xconf

Added: 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=598833&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LayoutType.java
(added)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LayoutType.java
Tue Nov 27 16:40:36 2007
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.om;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.cocoon.portal.services.LayoutFactory;
+
+
+/**
+ * A configured layout.
+ * This description is used to instantiate new layout objects by the {@link LayoutFactory}.
+ * A layout has an associated class and an associated type. The type is used to differentiate
+ * layout objects having the same class but providing different features. For example
+ * a composite layout can either be a row or a column - both use the same implementation
class
+ * but have different types.
+ *
+ * @version $Id$
+ */
+public class LayoutType {
+
+    protected String className;
+
+    protected boolean createId = false;
+
+    protected String defaultRendererName;
+
+    protected List rendererNames = new ArrayList(2);
+
+    protected String itemClassName;
+
+    protected boolean defaultIsStatic = false;
+
+    /**
+     * This is the name of the renderer used by default to render this layout object.
+     * @return the default renderer name
+     */
+    public String getDefaultRendererName() {
+        return defaultRendererName;
+    }
+
+    /**
+     * @param string
+     */
+    public void setDefaultRendererName(String string) {
+        defaultRendererName = string;
+    }
+
+    /**
+     * Each layout can have several associated renderers.
+     * @return the names of all allowed renderers.
+     */
+    public Collection getRendererNames() {
+        return this.rendererNames;
+    }
+
+    public void setRendererNames(List names) {
+        this.rendererNames = names;
+    }
+
+    /**
+     * Each composite layout object can contain items. This is the class name
+     * of the item implementation.
+     * @return The class name of the item.
+     */
+    public String getItemClassName() {
+        return this.itemClassName;
+    }
+
+    /**
+     * @param itemClassName The itemClassName to set.
+     */
+    public void setItemClassName(String itemClassName) {
+        this.itemClassName = itemClassName;
+    }
+
+    /**
+     * The name of the implementation class for this layout object.
+     * @return The class name.
+     */
+    public String getClassName() {
+        return className;
+    }
+
+    /**
+     * @param string
+     */
+    public void setClassName(String string) {
+        className = string;
+    }
+
+    /**
+     * Should the layout factory create a unique id for objects of this type?
+     */
+    public boolean createId() {
+        return this.createId;
+    }
+
+    public void setCreateId(boolean value) {
+        this.createId = value;
+    }
+
+    /**
+     * Default setting for static.
+     */
+    public boolean defaultIsStatic() {
+        return this.defaultIsStatic;
+    }
+
+    public void setDefaultIsStatic(boolean value) {
+        this.defaultIsStatic = value;
+    }
+}

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LayoutType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LayoutType.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/util/HtmlSaxParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/util/HtmlSaxParser.java?rev=598833&r1=598832&r2=598833&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/util/HtmlSaxParser.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/util/HtmlSaxParser.java
Tue Nov 27 16:40:36 2007
@@ -21,13 +21,12 @@
 import java.util.Iterator;
 import java.util.Properties;
 
-import org.apache.cocoon.xml.ContentHandlerWrapper;
-import org.apache.excalibur.xml.sax.XMLConsumer;
 import org.apache.xerces.parsers.AbstractSAXParser;
 import org.cyberneko.html.HTMLConfiguration;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
 import org.xml.sax.SAXException;
 import org.xml.sax.ext.LexicalHandler;
 
@@ -72,17 +71,24 @@
         }
     }
 
-    public static XMLConsumer getContentFilter(ContentHandler ch) {
+    /**
+     * Return a content filter which streams every element except body and html.
+     * @param ch
+     * @return A content handler.
+     */
+    public static ContentHandler getContentFilter(ContentHandler ch) {
+        if ( ch instanceof LexicalHandler ) {
+            return new ExtendedContentFilter(ch);
+        }
         return new ContentFilter(ch);
     }
 
-    protected static final class ContentFilter extends ContentHandlerWrapper {
+    protected static class ContentFilter implements ContentHandler {
+
+        protected final ContentHandler ch;
 
         public ContentFilter(ContentHandler ch) {
-            this.setContentHandler(ch);
-            if ( ch instanceof LexicalHandler ) {
-                this.setLexicalHandler((LexicalHandler)ch);
-            }
+            this.ch = ch;
         }
 
         /**
@@ -90,7 +96,7 @@
          */
         public void endElement(String uri, String loc, String raw) throws SAXException {
             if ( !loc.equals("html") && !loc.equals("body") ) {
-                super.endElement(uri, loc, raw);
+                this.ch.endElement(uri, loc, raw);
             }
         }
 
@@ -99,8 +105,115 @@
          */
         public void startElement(String uri, String loc, String raw, Attributes a) throws
SAXException {
             if ( !loc.equals("html") && !loc.equals("body") ) {
-                super.startElement(uri, loc, raw, a);
+                this.ch.startElement(uri, loc, raw, a);
             }
+        }
+
+        /**
+         * @see org.xml.sax.ContentHandler#characters(char[], int, int)
+         */
+        public void characters(char[] ch, int start, int length)
+                throws SAXException {
+            this.ch.characters(ch, start, length);
+        }
+
+        /**
+         * @see org.xml.sax.ContentHandler#endDocument()
+         */
+        public void endDocument() throws SAXException {
+            ch.endDocument();
+        }
+
+        /**
+         * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
+         */
+        public void endPrefixMapping(String prefix) throws SAXException {
+            ch.endPrefixMapping(prefix);
+        }
+
+        /**
+         * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
+         */
+        public void ignorableWhitespace(char[] ch, int start, int length)
+                throws SAXException {
+            this.ch.ignorableWhitespace(ch, start, length);
+        }
+
+        /**
+         * @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String, java.lang.String)
+         */
+        public void processingInstruction(String target, String data)
+                throws SAXException {
+            ch.processingInstruction(target, data);
+        }
+
+        /**
+         * @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator)
+         */
+        public void setDocumentLocator(Locator locator) {
+            ch.setDocumentLocator(locator);
+        }
+
+        /**
+         * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
+         */
+        public void skippedEntity(String name) throws SAXException {
+            ch.skippedEntity(name);
+        }
+
+        /**
+         * @see org.xml.sax.ContentHandler#startDocument()
+         */
+        public void startDocument() throws SAXException {
+            ch.startDocument();
+        }
+
+        /**
+         * @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
+         */
+        public void startPrefixMapping(String prefix, String uri)
+                throws SAXException {
+            ch.startPrefixMapping(prefix, uri);
+        }
+    }
+
+    protected static class ExtendedContentFilter extends ContentFilter implements LexicalHandler
{
+
+        protected final LexicalHandler lh;
+
+        public ExtendedContentFilter(final ContentHandler ch) {
+            super(ch);
+            this.lh = (LexicalHandler)ch;
+        }
+
+        public void comment(char[] arg0, int arg1, int arg2)
+                throws SAXException {
+            lh.comment(arg0, arg1, arg2);
+        }
+
+        public void endCDATA() throws SAXException {
+            lh.endCDATA();
+        }
+
+        public void endDTD() throws SAXException {
+            lh.endDTD();
+        }
+
+        public void endEntity(String arg0) throws SAXException {
+            lh.endEntity(arg0);
+        }
+
+        public void startCDATA() throws SAXException {
+            lh.startCDATA();
+        }
+
+        public void startDTD(String arg0, String arg1, String arg2)
+                throws SAXException {
+            lh.startDTD(arg0, arg1, arg2);
+        }
+
+        public void startEntity(String arg0) throws SAXException {
+            lh.startEntity(arg0);
         }
     }
 }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml?rev=598833&r1=598832&r2=598833&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
Tue Nov 27 16:40:36 2007
@@ -247,4 +247,18 @@
       +-->
     <configurator:bean-map id="org.apache.cocoon.portal.coplet.adapter.CopletAdapterMap"
                            type="org.apache.cocoon.portal.coplet.adapter.CopletAdapter"/>
+
+  <!--+
+      | Coplet Type map
+      |
+      +-->
+    <configurator:bean-map id="org.apache.cocoon.portal.om.CopletTypeMap"
+                           type="org.apache.cocoon.portal.om.CopletType"/>
+
+  <!--+
+      | Layout Type map
+      |
+      +-->
+    <configurator:bean-map id="org.apache.cocoon.portal.om.LayoutTypeMap"
+                           type="org.apache.cocoon.portal.om.LayoutType"/>
 </beans>

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/avalon/cocoon-portal-sample.xconf
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/avalon/cocoon-portal-sample.xconf?rev=598833&r1=598832&r2=598833&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/avalon/cocoon-portal-sample.xconf
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/avalon/cocoon-portal-sample.xconf
Tue Nov 27 16:40:36 2007
@@ -69,49 +69,49 @@
   <portal-layout-factory>
     <layouts>
       <layout type="column" 
-              class="org.apache.cocoon.portal.layout.impl.CompositeLayout">
+              class="org.apache.cocoon.portal.om.CompositeLayout">
         <renderers default="column">
           <renderer name="column"/>
         </renderers>
       </layout>
       <layout type="row" 
-              class="org.apache.cocoon.portal.layout.impl.CompositeLayout">
+              class="org.apache.cocoon.portal.om.CompositeLayout">
         <renderers default="row">
           <renderer name="row"/>
         </renderers>
       </layout>
       <layout type="tab" 
-              class="org.apache.cocoon.portal.layout.impl.CompositeLayout"
-              item-class="org.apache.cocoon.portal.layout.NamedItem"
+              class="org.apache.cocoon.portal.om.CompositeLayout"
+              item-class="org.apache.cocoon.portal.om.NamedItem"
               default-is-static="true">
         <renderers default="tab">
           <renderer name="tab"/>
         </renderers>
       </layout>
       <layout type="rawtab" 
-              class="org.apache.cocoon.portal.layout.impl.CompositeLayout"
-              item-class="org.apache.cocoon.portal.layout.NamedItem">
+              class="org.apache.cocoon.portal.om.CompositeLayout"
+              item-class="org.apache.cocoon.portal.om.NamedItem">
         <renderers default="rawtab">
           <renderer name="rawtab"/>
         </renderers>
       </layout>
       <layout type="linktab"
-              class="org.apache.cocoon.portal.layout.impl.CompositeLayout"
-              item-class="org.apache.cocoon.portal.layout.NamedItem"
+              class="org.apache.cocoon.portal.om.CompositeLayout"
+              item-class="org.apache.cocoon.portal.om.NamedItem"
               default-is-static="true">
         <renderers default="linktab">
           <renderer name="linktab"/>
         </renderers>
       </layout>
       <layout type="frame" 
-              class="org.apache.cocoon.portal.layout.impl.FrameLayout"
+              class="org.apache.cocoon.portal.om.FrameLayout"
               create-id="true">
         <renderers default="frame">
           <renderer name="frame"/>
         </renderers>
       </layout>
       <layout type="coplet" 
-              class="org.apache.cocoon.portal.layout.impl.CopletLayout">
+              class="org.apache.cocoon.portal.om.CopletLayout">
         <renderers default="window">
           <renderer name="window"/>
           <renderer name="nowindow"/>
@@ -119,7 +119,7 @@
         </renderers>
       </layout>
       <layout type="link"
-              class="org.apache.cocoon.portal.layout.impl.LinkLayout"
+              class="org.apache.cocoon.portal.om.LinkLayout"
               create-id="true">
         <renderers default="link">
           <renderer name="link"/>

Added: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/layout-types.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/layout-types.xml?rev=598833&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/layout-types.xml
(added)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/layout-types.xml
Tue Nov 27 16:40:36 2007
@@ -0,0 +1,126 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!--+
+    | This is a sample configuration for layout types.
+    |
+    | @version $Id$
+    +-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:portal="http://cocoon.apache.org/schema/portal"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+                           http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
+                           http://cocoon.apache.org/schema/portal http://cocoon.apache.org/schema/portal/cocoon-portal-1.0.xsd">
+
+    <bean name="org.apache.cocoon.portal.om.LayoutType/column"
+          class="org.apache.cocoon.portal.om.LayoutType">
+      <property name="className" value="org.apache.cocoon.portal.om.CompositeLayout"/>
+      <property name="defaultRendererName" value="column"/>
+      <property name="rendererNames">
+        <list>
+          <value>column</value>
+        </list>
+      </property>
+    </bean>
+
+    <bean name="org.apache.cocoon.portal.om.LayoutType/row"
+          class="org.apache.cocoon.portal.om.LayoutType">
+      <property name="className" value="org.apache.cocoon.portal.om.CompositeLayout"/>
+      <property name="defaultRendererName" value="row"/>
+      <property name="rendererNames">
+        <list>
+          <value>row</value>
+        </list>
+      </property>
+    </bean>
+
+    <bean name="org.apache.cocoon.portal.om.LayoutType/tab"
+          class="org.apache.cocoon.portal.om.LayoutType">
+      <property name="className" value="org.apache.cocoon.portal.om.CompositeLayout"/>
+      <property name="itemClassName" value="org.apache.cocoon.portal.om.NamedItem"/>
+      <property name="defaultRendererName" value="tab"/>
+      <property name="defaultIsStatic" value="true"/>
+      <property name="rendererNames">
+        <list>
+          <value>tab</value>
+        </list>
+      </property>
+    </bean>
+
+    <bean name="org.apache.cocoon.portal.om.LayoutType/rawtab"
+          class="org.apache.cocoon.portal.om.LayoutType">
+      <property name="className" value="org.apache.cocoon.portal.om.CompositeLayout"/>
+      <property name="itemClassName" value="org.apache.cocoon.portal.om.NamedItem"/>
+      <property name="defaultRendererName" value="rawtab"/>
+      <property name="rendererNames">
+        <list>
+          <value>rawtab</value>
+        </list>
+      </property>
+    </bean>
+
+    <bean name="org.apache.cocoon.portal.om.LayoutType/linktab"
+          class="org.apache.cocoon.portal.om.LayoutType">
+      <property name="className" value="org.apache.cocoon.portal.om.CompositeLayout"/>
+      <property name="itemClassName" value="org.apache.cocoon.portal.om.NamedItem"/>
+      <property name="defaultRendererName" value="linktab"/>
+      <property name="defaultIsStatic" value="true"/>
+      <property name="rendererNames">
+        <list>
+          <value>linktab</value>
+        </list>
+      </property>
+    </bean>
+
+    <bean name="org.apache.cocoon.portal.om.LayoutType/frame"
+          class="org.apache.cocoon.portal.om.LayoutType">
+      <property name="className" value="org.apache.cocoon.portal.om.FrameLayout"/>
+      <property name="defaultRendererName" value="frame"/>
+      <property name="createId" value="true"/>
+      <property name="rendererNames">
+        <list>
+          <value>frame</value>
+        </list>
+      </property>
+    </bean>
+
+    <bean name="org.apache.cocoon.portal.om.LayoutType/coplet"
+          class="org.apache.cocoon.portal.om.LayoutType">
+      <property name="className" value="org.apache.cocoon.portal.om.CopletLayout"/>
+      <property name="defaultRendererName" value="window"/>
+      <property name="rendererNames">
+        <list>
+          <value>window</value>
+          <value>nowindow</value>
+          <value>borderless-window</value>
+        </list>
+      </property>
+    </bean>
+
+    <bean name="org.apache.cocoon.portal.om.LayoutType/link"
+          class="org.apache.cocoon.portal.om.LayoutType">
+      <property name="className" value="org.apache.cocoon.portal.om.LinkLayout"/>
+      <property name="defaultRendererName" value="link"/>
+      <property name="createId" value="true"/>
+      <property name="rendererNames">
+        <list>
+          <value>link</value>
+        </list>
+      </property>
+    </bean>
+</beans>
\ No newline at end of file

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/layout-types.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/layout-types.xml
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message