geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r427645 - in /geronimo/xbean/trunk: xbean-spring-v1/src/main/java/org/apache/xbean/spring/context/v1/ xbean-spring-v1/src/test/resources/org/apache/xbean/spring/context/ xbean-spring-v2/src/main/java/org/apache/xbean/spring/context/v2/ xbea...
Date Tue, 01 Aug 2006 16:53:12 GMT
Author: gnodet
Date: Tue Aug  1 09:53:11 2006
New Revision: 427645

URL: http://svn.apache.org/viewvc?rev=427645&view=rev
Log:
XBEAN-24: Support mixed nested properties and complex elements

Modified:
    geronimo/xbean/trunk/xbean-spring-v1/src/main/java/org/apache/xbean/spring/context/v1/XBeanXmlBeanDefinitionParser.java
    geronimo/xbean/trunk/xbean-spring-v1/src/test/resources/org/apache/xbean/spring/context/pizza-xbean-properties.xml
    geronimo/xbean/trunk/xbean-spring-v2/src/main/java/org/apache/xbean/spring/context/v2/XBeanNamespaceHandler.java
    geronimo/xbean/trunk/xbean-spring-v2/src/test/resources/org/apache/xbean/spring/context/pizza-xbean-properties.xml

Modified: geronimo/xbean/trunk/xbean-spring-v1/src/main/java/org/apache/xbean/spring/context/v1/XBeanXmlBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-v1/src/main/java/org/apache/xbean/spring/context/v1/XBeanXmlBeanDefinitionParser.java?rev=427645&r1=427644&r2=427645&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-v1/src/main/java/org/apache/xbean/spring/context/v1/XBeanXmlBeanDefinitionParser.java
(original)
+++ geronimo/xbean/trunk/xbean-spring-v1/src/main/java/org/apache/xbean/spring/context/v1/XBeanXmlBeanDefinitionParser.java
Tue Aug  1 09:53:11 2006
@@ -24,7 +24,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.reflect.Method;
+import java.io.ByteArrayOutputStream;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Enumeration;
@@ -267,24 +267,28 @@
             addProperty(definition, metadata, element, name, value);
         }
         else {
-            // lets stry parse a nested properties file
+            StringBuffer buffer = new StringBuffer();
             NodeList childNodes = element.getChildNodes();
-            if (childNodes.getLength() == 1 && childNodes.item(0) instanceof Text)
{
-                Text text = (Text) childNodes.item(0);
-                ByteArrayInputStream in = new ByteArrayInputStream(text.getData().getBytes());
-                Properties properties = new Properties();
-                try {
-                    properties.load(in);
-                }
-                catch (IOException e) {
-                    return;
-                }
-                Enumeration enumeration = properties.propertyNames();
-                while (enumeration.hasMoreElements()) {
-                    name = (String) enumeration.nextElement();
-                    Object value = properties.getProperty(name);
-                    definition.getBeanDefinition().getPropertyValues().addPropertyValue(name,
value);
+            for (int i = 0, size = childNodes.getLength(); i < size; i++) {
+                Node node = childNodes.item(i);
+                if (node instanceof Text) {
+                    buffer.append(((Text) node).getData());
                 }
+            }
+
+            ByteArrayInputStream in = new ByteArrayInputStream(buffer.toString().getBytes());
+            Properties properties = new Properties();
+            try {
+                properties.load(in);
+            }
+            catch (IOException e) {
+                return;
+            }
+            Enumeration enumeration = properties.propertyNames();
+            while (enumeration.hasMoreElements()) {
+                name = (String) enumeration.nextElement();
+                Object value = getValue(properties.getProperty(name));
+                definition.getBeanDefinition().getPropertyValues().addPropertyValue(name,
value);
             }
         }
     }

Modified: geronimo/xbean/trunk/xbean-spring-v1/src/test/resources/org/apache/xbean/spring/context/pizza-xbean-properties.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-v1/src/test/resources/org/apache/xbean/spring/context/pizza-xbean-properties.xml?rev=427645&r1=427644&r2=427645&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-v1/src/test/resources/org/apache/xbean/spring/context/pizza-xbean-properties.xml
(original)
+++ geronimo/xbean/trunk/xbean-spring-v1/src/test/resources/org/apache/xbean/spring/context/pizza-xbean-properties.xml
Tue Aug  1 09:53:11 2006
@@ -3,11 +3,14 @@
 <beans xmlns:p="java://org.apache.xbean.spring.example">
 
   <p:PizzaService id="pizzaService">
-      topping   Salami
       cheese    Edam
-      size      17
+
+    <!-- properties can have complex elements mixed in -->
+    <p:topping>Salami</p:topping>
+
+       size      17
   </p:PizzaService>
-  
+
 </beans>
 
 <!-- END SNIPPET: xml -->

Modified: geronimo/xbean/trunk/xbean-spring-v2/src/main/java/org/apache/xbean/spring/context/v2/XBeanNamespaceHandler.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-v2/src/main/java/org/apache/xbean/spring/context/v2/XBeanNamespaceHandler.java?rev=427645&r1=427644&r2=427645&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-v2/src/main/java/org/apache/xbean/spring/context/v2/XBeanNamespaceHandler.java
(original)
+++ geronimo/xbean/trunk/xbean-spring-v2/src/main/java/org/apache/xbean/spring/context/v2/XBeanNamespaceHandler.java
Tue Aug  1 09:53:11 2006
@@ -343,24 +343,28 @@
             addProperty(definition, metadata, element, name, value);
         }
         else {
-            // lets stry parse a nested properties file
+            StringBuffer buffer = new StringBuffer();
             NodeList childNodes = element.getChildNodes();
-            if (childNodes.getLength() == 1 && childNodes.item(0) instanceof Text)
{
-                Text text = (Text) childNodes.item(0);
-                ByteArrayInputStream in = new ByteArrayInputStream(text.getData().getBytes());
-                Properties properties = new Properties();
-                try {
-                    properties.load(in);
-                }
-                catch (IOException e) {
-                    return;
-                }
-                Enumeration enumeration = properties.propertyNames();
-                while (enumeration.hasMoreElements()) {
-                    name = (String) enumeration.nextElement();
-                    Object value = properties.getProperty(name);
-                    definition.getBeanDefinition().getPropertyValues().addPropertyValue(name,
value);
+            for (int i = 0, size = childNodes.getLength(); i < size; i++) {
+                Node node = childNodes.item(i);
+                if (node instanceof Text) {
+                    buffer.append(((Text) node).getData());
                 }
+            }
+
+            ByteArrayInputStream in = new ByteArrayInputStream(buffer.toString().getBytes());
+            Properties properties = new Properties();
+            try {
+                properties.load(in);
+            }
+            catch (IOException e) {
+                return;
+            }
+            Enumeration enumeration = properties.propertyNames();
+            while (enumeration.hasMoreElements()) {
+                name = (String) enumeration.nextElement();
+                Object value = getValue(properties.getProperty(name));
+                definition.getBeanDefinition().getPropertyValues().addPropertyValue(name,
value);
             }
         }
     }

Modified: geronimo/xbean/trunk/xbean-spring-v2/src/test/resources/org/apache/xbean/spring/context/pizza-xbean-properties.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring-v2/src/test/resources/org/apache/xbean/spring/context/pizza-xbean-properties.xml?rev=427645&r1=427644&r2=427645&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-spring-v2/src/test/resources/org/apache/xbean/spring/context/pizza-xbean-properties.xml
(original)
+++ geronimo/xbean/trunk/xbean-spring-v2/src/test/resources/org/apache/xbean/spring/context/pizza-xbean-properties.xml
Tue Aug  1 09:53:11 2006
@@ -3,11 +3,14 @@
 <beans xmlns:p="java://org.apache.xbean.spring.example">
 
   <p:PizzaService id="pizzaService">
-      topping   Salami
       cheese    Edam
-      size      17
+
+    <!-- properties can have complex elements mixed in -->
+    <p:topping>Salami</p:topping>
+
+       size      17
   </p:PizzaService>
-  
+
 </beans>
 
 <!-- END SNIPPET: xml -->



Mime
View raw message