struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gvanma...@apache.org
Subject svn commit: r413788 - in /struts/shale/branches/mvn_reorg/shale-clay/src: main/java/org/apache/shale/clay/component/ main/java/org/apache/shale/clay/component/chain/ main/java/org/apache/shale/clay/config/ main/java/org/apache/shale/clay/config/beans/ ...
Date Tue, 13 Jun 2006 02:34:21 GMT
Author: gvanmatre
Date: Mon Jun 12 19:34:20 2006
New Revision: 413788

URL: http://svn.apache.org/viewvc?rev=413788&view=rev
Log:
Fix for issue SHALE-187

Added:
    struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/AbstractBean.java
  (with props)
    struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/SymbolBean.java
  (with props)
    struts/shale/branches/mvn_reorg/shale-clay/src/test/java/org/apache/shale/clay/config/DesigntimeTestCase.java
  (with props)
Modified:
    struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/component/Clay.java
    struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/component/chain/AbstractCommand.java
    struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/ClayXmlParser.java
    struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/AttributeBean.java
    struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentBean.java
    struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java
    struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/Builder.java
    struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/ElementBuilder.java
    struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/JsfDefaultBuilder.java
    struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/taglib/SymbolTag.java
    struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/utils/ClayAmalgam.java
    struts/shale/branches/mvn_reorg/shale-clay/src/test/java/org/apache/shale/clay/config/SymbolsTestCase.java

Modified: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/component/Clay.java
URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/component/Clay.java?rev=413788&r1=413787&r2=413788&view=diff
==============================================================================
--- struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/component/Clay.java
(original)
+++ struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/component/Clay.java
Mon Jun 12 19:34:20 2006
@@ -42,6 +42,7 @@
 import org.apache.shale.clay.config.beans.ComponentBean;
 import org.apache.shale.clay.config.beans.ConfigBean;
 import org.apache.shale.clay.config.beans.ConfigBeanFactory;
+import org.apache.shale.clay.config.beans.SymbolBean;
 import org.apache.shale.util.Messages;
 
 /**
@@ -211,7 +212,8 @@
      * </p>
      */
     public String getManagedBeanName() {
-        return (String) symbols.get(Globals.MANAGED_BEAN_MNEMONIC);
+        SymbolBean symbol = (SymbolBean) symbols.get(Globals.MANAGED_BEAN_MNEMONIC);    
+        return ((symbol != null) ? symbol.getValue() : null);
     }
     
     /**
@@ -221,7 +223,10 @@
      * </p>
      */
     public void setManagedBeanName(String mbeanMnemonic) {
-        symbols.put(Globals.MANAGED_BEAN_MNEMONIC, mbeanMnemonic);
+        SymbolBean symbol = new SymbolBean();
+        symbol.setName(Globals.MANAGED_BEAN_MNEMONIC);
+        symbol.setValue(mbeanMnemonic);
+        symbols.put(symbol.getName(), symbol);
     }
     
     /**

Modified: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/component/chain/AbstractCommand.java
URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/component/chain/AbstractCommand.java?rev=413788&r1=413787&r2=413788&view=diff
==============================================================================
--- struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/component/chain/AbstractCommand.java
(original)
+++ struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/component/chain/AbstractCommand.java
Mon Jun 12 19:34:20 2006
@@ -28,6 +28,7 @@
 import org.apache.commons.chain.Context;
 import org.apache.commons.chain.config.ConfigParser;
 import org.apache.shale.clay.config.Globals;
+import org.apache.shale.clay.config.beans.SymbolBean;
 import org.apache.shale.util.Messages;
 
 /**
@@ -102,8 +103,9 @@
         int i = buff.indexOf("@");
         replace: while (i > -1 && si.hasNext()) {
             Map.Entry e = (Map.Entry) si.next();
-            String key = (String) e.getKey();
-            String value = (String) (e.getValue() == null ? "" : e.getValue());
+            SymbolBean symbol = (SymbolBean) e.getValue();
+            String key = symbol.getName();
+            String value = (symbol.getValue() == null ? "" : symbol.getValue());
             i = (wasReplacementMade ? buff.indexOf("@") : i);
             if (i == -1)
               break replace;

Modified: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/ClayXmlParser.java
URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/ClayXmlParser.java?rev=413788&r1=413787&r2=413788&view=diff
==============================================================================
--- struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/ClayXmlParser.java
(original)
+++ struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/ClayXmlParser.java
Mon Jun 12 19:34:20 2006
@@ -23,14 +23,11 @@
 import java.net.URL;
 
 import org.apache.commons.digester.Digester;
-import org.apache.commons.digester.Rule;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.shale.clay.config.beans.ComponentBean;
 import org.apache.shale.clay.config.beans.ComponentConfigBean;
 import org.apache.shale.clay.config.beans.ConfigBean;
 import org.apache.shale.util.Messages;
-import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
@@ -101,38 +98,6 @@
         
     
     /**
-     * <p>This is a custom digester Rule that handles adding value pairs to 
-     * the symbols table on the {@link ComponentBean} nodes.</p>
-     */
-    private class SymbolRule extends Rule {
-
-        /**
-         * <p>Takes a peek at the last object on the digester stack.
-         * It assume that it will be a {@link ComponentBean}.  The
-         * attributes "name" and "value" are pulled
-         * from the <code>Attributes</code> sax collection and pushed
-         * into the {@link ComponentBean}'s <code>symbols</code> Map
-         * collection.  The character '@' is prepended to the symbol
-         * name if not existing.</p>  
-         */
-        public void begin(String qname, String name, Attributes attributes) throws Exception
{
-           ComponentBean b = (ComponentBean) super.digester.peek();
-           if (b != null && attributes != null) {
-                 String key = attributes.getValue("name");
-                 String value = attributes.getValue("value");
-                 if (name != null) {
-                    StringBuffer tmp = new StringBuffer(key);
-                    if (tmp.charAt(0) != '@')
-                      tmp.insert(0, '@');
-                        
-                    b.addSymbol(tmp.toString(), value);    
-                 }
-           }
-        }
-       
-    }
-
-    /**
      * <p>Loads a configuration file from a <code>url</code>.  The
      * input stream is identifed by the <code>watchDogName</code>.</p>
      */
@@ -186,6 +151,11 @@
             if (log.isInfoEnabled())
                 log.info(messages.getMessage("parser.load.rules"));
             
+            if (getConfig() instanceof ComponentConfigBean) {
+                if (((ComponentConfigBean) getConfig()).isDesigntime())
+                    digester.addBeanPropertySetter("*/description", "description");
+            }
+            
             digester.addObjectCreate(
                     "*/attributes/set",
                     org.apache.shale.clay.config.beans.AttributeBean.class);
@@ -195,7 +165,14 @@
                     "addAttribute",
                     "org.apache.shale.clay.config.beans.AttributeBean");
             
-            digester.addRule("*/symbols/set", new SymbolRule());
+            digester.addObjectCreate(
+                    "*/symbols/set",
+                    org.apache.shale.clay.config.beans.SymbolBean.class);
+            digester.addSetProperties("*/symbols/set");
+            digester.addSetNext(
+                    "*/symbols/set",
+                    "addSymbol",
+                    "org.apache.shale.clay.config.beans.SymbolBean");
             
             digester.addObjectCreate(
                     "*/valueChangeListener",

Added: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/AbstractBean.java
URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/AbstractBean.java?rev=413788&view=auto
==============================================================================
--- struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/AbstractBean.java
(added)
+++ struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/AbstractBean.java
Mon Jun 12 19:34:20 2006
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * $Id$
+ */
+
+
+package org.apache.shale.clay.config.beans;
+
+/**
+ * <p>Abstract class that provides a <code>description</code> property

+ * that is populated from the clay configuration file 
+ * when design time tool support is enabled.</p> 
+ *
+ */
+public abstract class AbstractBean {
+    /**
+     * <p>Metadata description provided in the clay configuration.</p>
+     */
+    private String description = null;
+
+    /**
+     * <p>Returns the <code>description</code> of the bean.</p>
+     */
+    public String getDescription() {
+        return description;
+    }
+
+    /**
+     * <p>Sets the <code>description</code> of the bean.</p>
+     */    
+    public void setDescription(String description) {
+        this.description = description;
+    }
+    
+}

Propchange: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/AbstractBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/AbstractBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/AttributeBean.java
URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/AttributeBean.java?rev=413788&r1=413787&r2=413788&view=diff
==============================================================================
--- struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/AttributeBean.java
(original)
+++ struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/AttributeBean.java
Mon Jun 12 19:34:20 2006
@@ -18,18 +18,17 @@
 
 package org.apache.shale.clay.config.beans;
 
-import java.io.Serializable;
 
 /**
  * <p>Represents a value for a component property or a tag attribute.
  * Instances of this class will be placed in the {@link ComponentBean}
  * <code>attributes</code> collection.</p>
  */
-public class AttributeBean implements Comparable, Serializable {
+public class AttributeBean extends SymbolBean {
 
-    private static final long serialVersionUID = 3689352130423305014L;
+	private static final long serialVersionUID = 3102689599088266442L;
 
-    /**
+	/**
      * <p>Mnemonic the signifies the a method binding expression.</p>
      */
     public static final String BINDING_TYPE_METHOD = "MB";
@@ -51,18 +50,7 @@
      * be preformed.</p>
      */
     public static final String BINDING_TYPE_NONE = "None";
-    
-    
-    /**
-     * <p>Name of the attribute in the target JSF object property.</p>
-     */    
-    private String name = null;
-
-    /**
-     * <p>Value of the named attribute in the target JSF object property.</p>
-     */
-    private String value = null;
-   
+       
     /**
      * <p>The parent meta component that contains this attribute in its
      * attributes collection.
@@ -95,49 +83,11 @@
          */
     public String toString() {
         StringBuffer buff = new StringBuffer();
-        buff.append("name=\"").append(name).append("\" value=\"").append(value)
+        buff.append("name=\"").append(getName()).append("\" value=\"").append(getValue())
             .append("\" bindingType=\"").append(bindingType).append("\"");
         return buff.toString();
     }
  
-    /**
-     * <p>Returns a name corresponding to an associated JSF object property.</p>
-     */
-    public String getName() {
-        return name;
-    }
-
-    /**
-     * <p>Returns the value of the attribute that can be a literal or a
-     * expression.</p>
-     */
-    public String getValue() {
-        return value;
-    }
-
-    /**
-     * <p>Sets the name of the attribute.</p>
-     */    
-    public void setName(String string) {
-        name = string;
-    }
-
-    /**
-     * <p>Sets the value of the attribute.</p>
-     */    
-    public void setValue(String string) {
-        value = string;
-    }
-   
-    /**
-     * <p>This implementation of the <code>Comparable</code> interface
makes
-     * the <code>name</code> property the compared key.</p>
-     */
-    public int compareTo(Object obj) {
-        AttributeBean item = (AttributeBean) obj;
-        
-        return item.getName().compareTo(getName());
-    }
     
     /**
      * <p>Returns the parent component containing this object instance.</p>

Modified: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentBean.java
URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentBean.java?rev=413788&r1=413787&r2=413788&view=diff
==============================================================================
--- struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentBean.java
(original)
+++ struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentBean.java
Mon Jun 12 19:34:20 2006
@@ -42,7 +42,7 @@
  * </dl>
  * </p>
  */
-public class ComponentBean implements Comparable, Serializable {
+public class ComponentBean extends AbstractBean implements Comparable, Serializable {
     
     private static final long serialVersionUID = 3907217039524312373L;
 
@@ -648,12 +648,19 @@
     }
     
     /**
-     * <p>Adds a symbol identified by the <code>key</code>
-     * and replacement <code>value</code> to the symbols 
-     * collection.</p>  
+     * <p>Adds a symbol identified by the 
+     * {@link SymbolBean} to the symbols collection.</p>  
      */
-    public void addSymbol(String key, String value) {
-       symbols.put(key, value);     
+    public void addSymbol(SymbolBean symbol) {
+       if (symbol.getName() != null && symbol.getName().length() > 0) {
+            StringBuffer buff = new StringBuffer(symbol.getName());
+            if (buff.charAt(0) != '@') { 
+               buff.insert(0, '@');
+               symbol.setName(buff.toString());
+            }
+     
+            symbols.put(symbol.getName(), symbol);
+        }
     }
     
     /**
@@ -663,6 +670,22 @@
      */
     public Map getSymbols() {
        return symbols;    
+    }
+    
+    
+    /**
+     * <p>Returns a {@link SymbolBean} from the <code>symbols</code>
+     * Map by <code>name</code>.  Prepends a '@' character to the 
+     * <code>name</code> if it doesn't exist.</p>  
+     */
+    public SymbolBean getSymbol(String name) {
+        StringBuffer tmp = new StringBuffer(name);
+        if (tmp.charAt(0) != '@')
+            tmp.insert(0, '@');
+        
+        SymbolBean symbol = (SymbolBean) symbols.get(tmp.toString());
+        
+        return symbol;
     }
     
 }

Modified: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java
URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java?rev=413788&r1=413787&r2=413788&view=diff
==============================================================================
--- struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java
(original)
+++ struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java
Mon Jun 12 19:34:20 2006
@@ -102,6 +102,32 @@
      */
     protected transient ServletContext context = null;
     
+    
+    /**
+     * <p>Flag that indicates the current mode is design time.
+     * In design time mode, the descriptions in the clay
+     * configuration files will populate the <code>description</code>
+     * property of the target {@link AbstractBean}.</p>
+     */
+    private boolean isDesigntime = false;
+    
+    /**
+     * <p>Returns <code>true</code> if the current mode
+     * is design time.</p>
+     */
+    public boolean isDesigntime() {
+       return isDesigntime;
+    }
+    
+    /**
+     * <p>Sets the design time to somthing other than
+     * the default <code>false</code> value.</p>
+     */
+    public void setDesigntime(boolean isDesigntime) {
+       this.isDesigntime = isDesigntime;
+    }
+    
+    
     /**
      * <p>Initialization method that is passed the <code>ServletContext</code>
      * as a parameter.  Loads the <code>sufixes</code> for the ServletContext

@@ -481,6 +507,9 @@
         // inherit late binding type
         if (a.getBindingType() == null)
             a.setBindingType(a.getIsAParent().getBindingType());
+        
+        if (a.getDescription() == null) 
+            a.setDescription(a.getIsAParent().getDescription());
                 
         // set final indicator
         a.setInheritanceFinal(true);
@@ -516,6 +545,9 @@
 
             if (b.getFacetName() == null)
                 b.setFacetName(b.getIsAParent().getFacetName());
+            
+            if (b.getDescription() == null)
+                b.setDescription(b.getIsAParent().getDescription());
 
             // inherit parents attributes
             Iterator pi = b.getIsAParent().getAttributeIterator();

Added: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/SymbolBean.java
URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/SymbolBean.java?rev=413788&view=auto
==============================================================================
--- struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/SymbolBean.java
(added)
+++ struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/SymbolBean.java
Mon Jun 12 19:34:20 2006
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * $Id$
+ */
+
+package org.apache.shale.clay.config.beans;
+
+import java.io.Serializable;
+
+
+/**
+ * <p>A symbol represents a variable replaced in a 
+ * JSF binding expression.  Within the expression 
+ * symbols are identified by the '@' prefix.</p>  
+ *
+ */
+public class SymbolBean extends AbstractBean implements Serializable,
+        Comparable {
+
+    private static final long serialVersionUID = -584466364674399355L;
+
+    /**
+     * <p>Name of the symbol in the target JSF object property.</p>
+     */    
+    private String name = null;
+
+    /**
+     * <p>Value of the named symbol in the target JSF object property.</p>
+     */
+    private String value = null;
+   
+
+    /**
+     * <p>Returns a name corresponding to an associated JSF object property.</p>
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * <p>Returns the value of the attribute that can be a literal or a
+     * expression.</p>
+     */
+    public String getValue() {
+        return value;
+    }
+
+    /**
+     * <p>Sets the name of the attribute.</p>
+     */    
+    public void setName(String string) {
+        name = string;
+    }
+
+    /**
+     * <p>Sets the value of the attribute.</p>
+     */    
+    public void setValue(String string) {
+        value = string;
+    }
+   
+    /**
+     * <p>This implementation of the <code>Comparable</code> interface
makes
+     * the <code>name</code> property the compared key.</p>
+     */
+    public int compareTo(Object obj) {
+        SymbolBean item = (SymbolBean) obj;
+        
+        return item.getName().compareTo(getName());
+    }
+   
+        
+    public String toString() {
+        StringBuffer buff = new StringBuffer();
+        buff.append("name=\"").append(name).append("\" value=\"").append(value)
+            .append("\"");
+        return buff.toString();
+    }
+
+}

Propchange: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/SymbolBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/config/beans/SymbolBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/Builder.java
URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/Builder.java?rev=413788&r1=413787&r2=413788&view=diff
==============================================================================
--- struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/Builder.java
(original)
+++ struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/Builder.java
Mon Jun 12 19:34:20 2006
@@ -28,6 +28,7 @@
 import org.apache.shale.clay.config.beans.ConfigBean;
 import org.apache.shale.clay.config.beans.ConfigBeanFactory;
 import org.apache.shale.clay.config.beans.ElementBean;
+import org.apache.shale.clay.config.beans.SymbolBean;
 import org.apache.shale.clay.parser.Node;
 import org.apache.shale.clay.parser.Token;
 import org.apache.shale.util.Messages;
@@ -310,7 +311,10 @@
                     //any token that is not an attribute in the target becomes a symbol
                     StringBuffer identifier = new StringBuffer((String) e.getKey());
                     identifier.insert(0, '@');
-                    target.addSymbol(identifier.toString(), valueToken.getRawText()); 
+                    SymbolBean symbol = new SymbolBean();
+                    symbol.setName(identifier.toString());
+                    symbol.setValue(valueToken.getRawText());
+                    target.addSymbol(symbol); 
                 }
             }    
         }

Modified: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/ElementBuilder.java
URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/ElementBuilder.java?rev=413788&r1=413787&r2=413788&view=diff
==============================================================================
--- struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/ElementBuilder.java
(original)
+++ struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/ElementBuilder.java
Mon Jun 12 19:34:20 2006
@@ -31,6 +31,7 @@
 import org.apache.shale.clay.config.beans.ConfigBeanFactory;
 import org.apache.shale.clay.config.beans.ConverterBean;
 import org.apache.shale.clay.config.beans.ElementBean;
+import org.apache.shale.clay.config.beans.SymbolBean;
 import org.apache.shale.clay.config.beans.ValidatorBean;
 import org.apache.shale.clay.config.beans.ValueChangeListenerBean;
 import org.apache.shale.clay.parser.Node;
@@ -225,8 +226,16 @@
                 String name = (String) child.getAttributes().get("name");
                 String value = (String) child.getAttributes().get("value");
                 
-                if (name != null && name.length() > 0)
-                    target.addSymbol(name, value);
+                if (name != null && name.length() > 0) {
+                    SymbolBean symbol = new SymbolBean();
+                    StringBuffer tmp = new StringBuffer(name);
+                    if (tmp.charAt(0) != '@')
+                       tmp.insert(0, '@');
+                    
+                    symbol.setName(tmp.toString());
+                    symbol.setValue(value);
+                    target.addSymbol(symbol);
+                }
             }
         }
     }

Modified: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/JsfDefaultBuilder.java
URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/JsfDefaultBuilder.java?rev=413788&r1=413787&r2=413788&view=diff
==============================================================================
--- struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/JsfDefaultBuilder.java
(original)
+++ struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/JsfDefaultBuilder.java
Mon Jun 12 19:34:20 2006
@@ -26,6 +26,7 @@
 import org.apache.shale.clay.config.beans.ComponentBean;
 import org.apache.shale.clay.config.beans.ConverterBean;
 import org.apache.shale.clay.config.beans.ElementBean;
+import org.apache.shale.clay.config.beans.SymbolBean;
 import org.apache.shale.clay.config.beans.ValidatorBean;
 import org.apache.shale.clay.config.beans.ValueChangeListenerBean;
 import org.apache.shale.clay.parser.Node;
@@ -159,8 +160,15 @@
     protected void addSymbol(Node node, ElementBean target) {
         String value = (String) node.getAttributes().get("value");
         String name = (String) node.getAttributes().get("name");
-        if (name != null) {
-            target.addSymbol(name, value);    
+        if (name != null && name.length() > 0) {
+            SymbolBean symbol = new SymbolBean();
+            StringBuffer tmp = new StringBuffer(name);
+            if (tmp.charAt(0) != '@')
+               tmp.insert(0, '@');
+            
+            symbol.setName(tmp.toString());
+            symbol.setValue(value);
+            target.addSymbol(symbol);    
         }
     }
 

Modified: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/taglib/SymbolTag.java
URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/taglib/SymbolTag.java?rev=413788&r1=413787&r2=413788&view=diff
==============================================================================
--- struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/taglib/SymbolTag.java
(original)
+++ struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/taglib/SymbolTag.java
Mon Jun 12 19:34:20 2006
@@ -21,6 +21,7 @@
 import javax.servlet.jsp.tagext.TagSupport;
 
 import org.apache.shale.clay.component.Clay;
+import org.apache.shale.clay.config.beans.SymbolBean;
 import org.apache.shale.util.Messages;
 
 /**
@@ -108,7 +109,10 @@
           if (tmp.charAt(0) != '@')
             tmp.insert(0, '@');
           
-          clayParent.getSymbols().put(tmp.toString(), value);          
+          SymbolBean symbol = new SymbolBean();
+          symbol.setName(tmp.toString());
+          symbol.setValue(value);
+          clayParent.getSymbols().put(symbol.getName(), symbol.getValue());          
           
           return super.doStartTag();
     

Modified: struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/utils/ClayAmalgam.java
URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/utils/ClayAmalgam.java?rev=413788&r1=413787&r2=413788&view=diff
==============================================================================
--- struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/utils/ClayAmalgam.java
(original)
+++ struts/shale/branches/mvn_reorg/shale-clay/src/main/java/org/apache/shale/clay/utils/ClayAmalgam.java
Mon Jun 12 19:34:20 2006
@@ -36,6 +36,7 @@
 import org.apache.shale.clay.config.beans.ConfigBean;
 import org.apache.shale.clay.config.beans.ConfigBeanFactory;
 import org.apache.shale.clay.config.beans.ElementBean;
+import org.apache.shale.clay.config.beans.SymbolBean;
 import org.apache.shale.faces.ShaleConstants;
 import org.apache.shale.util.Messages;
 import org.apache.shale.util.Tags;
@@ -408,7 +409,10 @@
 
               //prepend the var to the generated key
               id.insert(0, var + "."); 
-              target.addSymbol(Globals.MANAGED_BEAN_MNEMONIC, id.toString());
+              SymbolBean symbol = new SymbolBean();
+              symbol.setName(Globals.MANAGED_BEAN_MNEMONIC);
+              symbol.setValue(id.toString());
+              target.addSymbol(symbol);
               
               
               namingContainer.addChild(target);

Added: struts/shale/branches/mvn_reorg/shale-clay/src/test/java/org/apache/shale/clay/config/DesigntimeTestCase.java
URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-clay/src/test/java/org/apache/shale/clay/config/DesigntimeTestCase.java?rev=413788&view=auto
==============================================================================
--- struts/shale/branches/mvn_reorg/shale-clay/src/test/java/org/apache/shale/clay/config/DesigntimeTestCase.java
(added)
+++ struts/shale/branches/mvn_reorg/shale-clay/src/test/java/org/apache/shale/clay/config/DesigntimeTestCase.java
Mon Jun 12 19:34:20 2006
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * 
+ * Licensed 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.shale.clay.config;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.shale.clay.config.beans.AttributeBean;
+import org.apache.shale.clay.config.beans.ComponentBean;
+import org.apache.shale.clay.config.beans.ComponentConfigBean;
+import org.apache.shale.clay.config.beans.SymbolBean;
+
+public class DesigntimeTestCase extends AbstractTestCaseConfig {
+
+    // Construct a new instance of this test case.
+    public DesigntimeTestCase(String name) {
+        super(name);
+    }
+
+    // Return the tests included in this test case.
+    public static Test suite() {
+
+        return (new TestSuite(DesigntimeTestCase.class));
+
+    }
+
+    public void setUp() {
+        super.setUp();
+    }
+
+    public void testDesigntimeOn() {
+        ((ComponentConfigBean) standardConfigBean).setDesigntime(true);       
+        loadConfigFiles(null, null);
+        
+        ComponentBean bean = standardConfigBean.getElement("clay");
+        assertNotNull(bean);
+        
+        String description = bean.getDescription();
+        assertNotNull(description);
+        
+        assertTrue(description.startsWith("This component builds a sub component tree and
attaches"));
+        
+        AttributeBean attr = bean.getAttribute("managedBeanName");
+        assertNotNull(attr);
+        
+        description = attr.getDescription();
+        assertEquals("A symbol that is used to alias the bound backing bean.", description);
+
+        
+        bean = standardConfigBean.getElement("baseHtml");
+        assertNotNull(bean);
+        
+        description = bean.getDescription();
+        assertNotNull(description);
+        
+        assertTrue(description.startsWith("Abstract base component definition"));
+        
+        SymbolBean symbol = (SymbolBean) bean.getSymbols().get("@class");
+        assertNotNull(symbol);
+        
+        description = symbol.getDescription();
+        assertNotNull(description);
+        
+        assertEquals("The default value of the styleClass attribute.", description);
+        
+        
+    }
+
+    
+    public void testDesigntimeOff() {
+        ((ComponentConfigBean) standardConfigBean).setDesigntime(false);       
+        loadConfigFiles(null, null);
+        
+        ComponentBean bean = standardConfigBean.getElement("clay");
+        assertNotNull(bean);
+        
+        String description = bean.getDescription();
+        assertNull(description);
+               
+        AttributeBean attr = bean.getAttribute("managedBeanName");
+        assertNotNull(attr);
+        
+        description = attr.getDescription();
+        assertNull(description);
+
+        bean = standardConfigBean.getElement("baseHtml");
+        assertNotNull(bean);
+        
+        description = bean.getDescription();
+        assertNull(description);
+
+        SymbolBean symbol = (SymbolBean) bean.getSymbols().get("@class");
+        assertNotNull(symbol);
+        
+        description = symbol.getDescription();
+        assertNull(description);
+        
+    }
+
+
+    public void testDesigntimeOnInheritance() {
+        ((ComponentConfigBean) standardConfigBean).setDesigntime(true);       
+        loadConfigFiles(null, null);
+
+        ComponentBean bean1 = standardConfigBean.getElement("f:converter");
+        assertNotNull(bean1);
+        
+        assertNotNull(bean1.getDescription());
+        
+        ComponentBean bean2 = standardConfigBean.getElement(bean1.getExtends());
+        assertNotNull(bean2);
+
+        assertNotNull(bean2.getDescription());
+        assertEquals(bean2.getDescription(), bean1.getDescription());
+
+    }     
+        
+}

Propchange: struts/shale/branches/mvn_reorg/shale-clay/src/test/java/org/apache/shale/clay/config/DesigntimeTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/shale/branches/mvn_reorg/shale-clay/src/test/java/org/apache/shale/clay/config/DesigntimeTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: struts/shale/branches/mvn_reorg/shale-clay/src/test/java/org/apache/shale/clay/config/SymbolsTestCase.java
URL: http://svn.apache.org/viewvc/struts/shale/branches/mvn_reorg/shale-clay/src/test/java/org/apache/shale/clay/config/SymbolsTestCase.java?rev=413788&r1=413787&r2=413788&view=diff
==============================================================================
--- struts/shale/branches/mvn_reorg/shale-clay/src/test/java/org/apache/shale/clay/config/SymbolsTestCase.java
(original)
+++ struts/shale/branches/mvn_reorg/shale-clay/src/test/java/org/apache/shale/clay/config/SymbolsTestCase.java
Mon Jun 12 19:34:20 2006
@@ -29,6 +29,7 @@
 import org.apache.shale.clay.config.beans.AttributeBean;
 import org.apache.shale.clay.config.beans.ComponentBean;
 import org.apache.shale.clay.config.beans.ElementBean;
+import org.apache.shale.clay.config.beans.SymbolBean;
 import org.apache.shale.faces.ShaleConstants;
 import org.apache.shale.util.Tags;
 
@@ -123,6 +124,14 @@
         
     }
    
+    //factory method for creating a symbol bean
+    private SymbolBean createSymbol(String name, String value) {
+        SymbolBean symbol = new SymbolBean();
+        symbol.setName(name);
+        symbol.setValue(value);
+        return symbol;
+    }   
+    
     // test symbolic property replacement
     public void testSymbolicProperties() throws Exception {
            javax.faces.component.html.HtmlOutputText child = (javax.faces.component.html.HtmlOutputText)

@@ -140,7 +149,7 @@
            displayElement.setComponentType("javax.faces.HtmlOutputText");
            displayElement.setId("testId");
            displayElement.addAttribute(attr);
-           displayElement.addSymbol("@value", "10");
+           displayElement.addSymbol(createSymbol("@value", "10"));
                       
            ClayContext clayContext = new ClayContext();
            clayContext.setFacesContext(facesContext);
@@ -163,7 +172,7 @@
                         facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");

            assertNotNull("javax.faces.HtmlOutputText", child);
 
-           displayElement.addSymbol("@value", "#{value}");
+           displayElement.addSymbol(createSymbol("@value", "#{value}"));
            attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
            servletContext.setAttribute("value", "10");
           
@@ -183,7 +192,7 @@
                  facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");

            assertNotNull("javax.faces.HtmlOutputText", child);
 
-           displayElement.addSymbol("@value", null);
+           displayElement.addSymbol(createSymbol("@value", null));
            attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
           
            clayContext.setFacesContext(facesContext);
@@ -203,7 +212,7 @@
                      facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");

            assertNotNull("javax.faces.HtmlOutputText", child);
 
-           displayElement.addSymbol("@value", "");
+           displayElement.addSymbol(createSymbol("@value", ""));
            attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
           
            clayContext.setFacesContext(facesContext);
@@ -239,9 +248,9 @@
                      facesContext.getApplication().createComponent("javax.faces.HtmlOutputText");

            assertNotNull("javax.faces.HtmlOutputText", child);
 
-           displayElement.addSymbol("@test1", "rock");
-           displayElement.addSymbol("@test2", "stop");
-           displayElement.addSymbol("@test3", "drop");
+           displayElement.addSymbol(createSymbol("@test1", "rock"));
+           displayElement.addSymbol(createSymbol("@test2", "stop"));
+           displayElement.addSymbol(createSymbol("@test3", "drop"));
 
            clayContext.setFacesContext(facesContext);
            clayContext.setChild(child);
@@ -269,7 +278,7 @@
         displayElement.setJsfid("inputText");
         displayElement.setComponentType("javax.faces.HtmlOutputText");
         displayElement.setId("@wynn");
-        displayElement.addSymbol("@wynn", "test");
+        displayElement.addSymbol(createSymbol("@wynn", "test"));
         
         ClayContext clayContext = new ClayContext();
         clayContext.setFacesContext(facesContext);
@@ -300,7 +309,7 @@
         displayElement.setJsfid("inputText");
         displayElement.setComponentType("javax.faces.HtmlOutputText");
         displayElement.setId("@wynn");
-        displayElement.addSymbol("@wynn", null);
+        displayElement.addSymbol(createSymbol("@wynn", null));
         
         clayContext = new ClayContext();
         clayContext.setFacesContext(facesContext);
@@ -371,8 +380,8 @@
         displayElement.setComponentType("javax.faces.HtmlOutputText");
         displayElement.setId("testId");
         displayElement.addAttribute(attr);
-        displayElement.addSymbol("@[ab]", "43");
-        displayElement.addSymbol("@[a]", "67");
+        displayElement.addSymbol(createSymbol("@[ab]", "43"));
+        displayElement.addSymbol(createSymbol("@[a]", "67"));
              
         ClayContext clayContext = new ClayContext();
         clayContext.setFacesContext(facesContext);
@@ -397,8 +406,8 @@
         assertNotNull("javax.faces.HtmlOutputText", child);
 
         attr.setValue("@{a}@{ab}");  //symbolic attribute 
-        displayElement.addSymbol("@{ab}", "43");
-        displayElement.addSymbol("@{a}", "67");
+        displayElement.addSymbol(createSymbol("@{ab}", "43"));
+        displayElement.addSymbol(createSymbol("@{a}", "67"));
 
         clayContext.setChild(child);
 
@@ -414,8 +423,8 @@
         assertNotNull("javax.faces.HtmlOutputText", child);
 
         attr.setValue("@(a)@(ab)");  //symbolic attribute 
-        displayElement.addSymbol("@(ab)", "43");
-        displayElement.addSymbol("@(a)", "67");
+        displayElement.addSymbol(createSymbol("@(ab)", "43"));
+        displayElement.addSymbol(createSymbol("@(a)", "67"));
 
         clayContext.setChild(child);
 
@@ -436,25 +445,25 @@
         ComponentBean bean = standardConfigBean.getElement("baseSymbolLabel");
         assertNotNull(bean);
         //look for a base symbol definition
-        String symbol = (String) bean.getSymbols().get("@mystyle");
+        SymbolBean symbol = (SymbolBean) bean.getSymbols().get("@mystyle");
         assertNotNull(symbol);
-        assertEquals("@mystyle == color:blue", "color:blue", symbol);
+        assertEquals("@mystyle == color:blue", "color:blue", symbol.getValue());
 
         // symbol1Label extends baseSymbolLabel
         bean = standardConfigBean.getElement("symbol1Label");
         assertNotNull(bean);
         //look for inherited symbol
-        symbol = (String) bean.getSymbols().get("@mystyle");
+        symbol = (SymbolBean) bean.getSymbols().get("@mystyle");
         assertNotNull(symbol);
-        assertEquals("@mystyle == color:blue", "color:blue", symbol);
+        assertEquals("@mystyle == color:blue", "color:blue", symbol.getValue());
 
         // symbol2Label extends symbol1Label
         bean = standardConfigBean.getElement("symbol2Label");
         assertNotNull(bean);
         //look for an overridden symbol
-        symbol = (String) bean.getSymbols().get("@mystyle");
+        symbol = (SymbolBean) bean.getSymbols().get("@mystyle");
         assertNotNull(symbol);
-        assertEquals("@mystyle == color:red", "color:red", symbol);
+        assertEquals("@mystyle == color:red", "color:red", symbol.getValue());
 
         
         //test nested/inner element inheritance
@@ -467,14 +476,14 @@
             ElementBean ebean = (ElementBean) ei.next();
             if (ebean.getRenderId() == 1) {
                 //look for inherited symbol
-                symbol = (String) ebean.getSymbols().get("@mystyle");
+                symbol = (SymbolBean) ebean.getSymbols().get("@mystyle");
                 assertNotNull(symbol);
-                assertEquals("@mystyle == color:blue", "color:blue", symbol);           
    
+                assertEquals("@mystyle == color:blue", "color:blue", symbol.getValue());
               
             } else if (ebean.getRenderId() == 2) {
                 //look for an overridden symbol
-                symbol = (String) ebean.getSymbols().get("@mystyle");
+                symbol = (SymbolBean) ebean.getSymbols().get("@mystyle");
                 assertNotNull(symbol);
-                assertEquals("@mystyle == color:red", "color:red", symbol);
+                assertEquals("@mystyle == color:red", "color:red", symbol.getValue());
                 
             }
         }



Mime
View raw message