[jboss-cvs] JBossAS SVN: r110332 - in branches/JBPAPP_5_1/system-jmx/src: resources/tests/org/jboss/test/system/metadata/value/valuefactory/test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 12 07:47:35 EST 2011


Author: alesj
Date: 2011-01-12 07:47:34 -0500 (Wed, 12 Jan 2011)
New Revision: 110332

Modified:
   branches/JBPAPP_5_1/system-jmx/src/main/org/jboss/system/metadata/ServiceMetaDataParser.java
   branches/JBPAPP_5_1/system-jmx/src/resources/tests/org/jboss/test/system/metadata/value/valuefactory/test/NullParameter.xml
Log:
[JBPAPP-4041]; handle whitespaces.


Modified: branches/JBPAPP_5_1/system-jmx/src/main/org/jboss/system/metadata/ServiceMetaDataParser.java
===================================================================
--- branches/JBPAPP_5_1/system-jmx/src/main/org/jboss/system/metadata/ServiceMetaDataParser.java	2011-01-12 12:19:59 UTC (rev 110331)
+++ branches/JBPAPP_5_1/system-jmx/src/main/org/jboss/system/metadata/ServiceMetaDataParser.java	2011-01-12 12:47:34 UTC (rev 110332)
@@ -49,6 +49,7 @@
  * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
  * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
  * @version $Revision$
  */
 public class ServiceMetaDataParser
@@ -616,7 +617,7 @@
          Element valueEl = (Element) child;
          if ("value".equals(valueEl.getTagName()))
          {            
-            valueType = ((Element)child).getAttribute("class");
+            valueType = valueEl.getAttribute("class");
             if (valueType.length() == 0)
                valueType = null;
             
@@ -626,13 +627,39 @@
          }
          else if ("null".equals(valueEl.getTagName()) == false)
          {
-            throw new RuntimeException("Element " + ((Element)child).getTagName() + " not supported as a child of value-factory/parameter in a -service.xml");
+            throw new RuntimeException("Element " + valueEl.getTagName() + " not supported as a child of value-factory/parameter in a -service.xml");
          }
       }
       else
       {
-         textValue = getElementTextContent(el);
-      }         
+         Node nextChild = child.getNextSibling();
+         while (nextChild != null && nextChild.getNodeType() != Node.ELEMENT_NODE)
+            nextChild = nextChild.getNextSibling();
+
+         // we have nested element in whitespace
+         if (nextChild instanceof Element)
+         {
+            Element valueEl = (Element) nextChild;
+            if ("value".equals(valueEl.getTagName()))
+            {
+               valueType = valueEl.getAttribute("class");
+               if (valueType.length() == 0)
+                  valueType = null;
+
+               textValue = getElementTextContent(valueEl);
+               // Deal with any trim/replace from the outer element
+               textValue = trimAndReplace(textValue, getTrim(el), getReplace(el));
+            }
+            else if ("null".equals(valueEl.getTagName()) == false)
+            {
+               throw new RuntimeException("Element " + valueEl.getTagName() + " not supported as a child of value-factory/parameter in a -service.xml");
+            }
+         }
+         else
+         {
+            textValue = getElementTextContent(el);
+         }
+      }
       
       return new ServiceValueFactoryParameterMetaData(textValue, parameterType, valueType);
    }

Modified: branches/JBPAPP_5_1/system-jmx/src/resources/tests/org/jboss/test/system/metadata/value/valuefactory/test/NullParameter.xml
===================================================================
--- branches/JBPAPP_5_1/system-jmx/src/resources/tests/org/jboss/test/system/metadata/value/valuefactory/test/NullParameter.xml	2011-01-12 12:19:59 UTC (rev 110331)
+++ branches/JBPAPP_5_1/system-jmx/src/resources/tests/org/jboss/test/system/metadata/value/valuefactory/test/NullParameter.xml	2011-01-12 12:47:34 UTC (rev 110332)
@@ -3,7 +3,9 @@
 <mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
    <attribute name="Attribute">
       <value-factory bean="bean" method="method" default="default">
-         <parameter><null/>1</parameter>
+         <parameter>
+            <null/>
+         </parameter>
          <parameter>2</parameter>
       </value-factory>
    </attribute>



More information about the jboss-cvs-commits mailing list