geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r514679 - in /geronimo/xbean/trunk/xbean-spring/src: main/java/org/apache/xbean/spring/context/v2c/ test/java/org/apache/xbean/spring/context/ test/resources/org/apache/xbean/spring/context/
Date Mon, 05 Mar 2007 14:44:25 GMT
Author: gnodet
Date: Mon Mar  5 06:44:24 2007
New Revision: 514679

URL: http://svn.apache.org/viewvc?view=rev&rev=514679
Log:
XBEAN-80: Custom Map values aren't parsed properly (using spring 2.0)

Modified:
    geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/v2c/XBeanNamespaceHandler.java
    geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/FavoriteUsingSpringTest.java
    geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/favorite-normal.xml
    geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/favorite-xbean.xml

Modified: geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/v2c/XBeanNamespaceHandler.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/v2c/XBeanNamespaceHandler.java?view=diff&rev=514679&r1=514678&r2=514679
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/v2c/XBeanNamespaceHandler.java
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/v2c/XBeanNamespaceHandler.java
Mon Mar  5 06:44:24 2007
@@ -618,13 +618,43 @@
 
                     Object keyValue = getValue(key, null);
 
-                    Object value = getValue(getElementText(childElement), null);
+                    Element valueElement = getFirstChildElement(childElement);
+                    Object value;
+                    if (valueElement != null) {
+                        String valueElUri = valueElement.getNamespaceURI();
+                        String valueElLocalName = valueElement.getLocalName();
+                        if (valueElUri == null || 
+                            valueElUri.equals(SPRING_SCHEMA) || 
+                            valueElUri.equals(SPRING_SCHEMA_COMPAT) ||
+                            valueElUri.equals(BeanDefinitionParserDelegate.BEANS_NAMESPACE_URI))
{
+                            if (BeanDefinitionParserDelegate.BEAN_ELEMENT.equals(valueElLocalName))
{
+                                value = parserContext.getDelegate().parseBeanDefinitionElement(valueElement,
null);
+                            } else {
+                                value = parserContext.getDelegate().parsePropertySubElement(valueElement,
null);
+                            }
+                        } else {
+                            value = parserContext.getDelegate().parseCustomElement(valueElement);
+                        }
+                    } else {
+                        value = getElementText(childElement);
+                    }
 
                     map.put(keyValue, value);
                 }
             }
         }
         return map;
+    }
+
+    protected Element getFirstChildElement(Element element) {
+        NodeList nl = element.getChildNodes();
+        for (int i = 0; i < nl.getLength(); i++) {
+            Node node = nl.item(i);
+            if (node instanceof Element) {
+                return (Element) node;
+            }
+        }
+        return null;
     }
 
     protected boolean isMap(Class type) {

Modified: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/FavoriteUsingSpringTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/FavoriteUsingSpringTest.java?view=diff&rev=514679&r1=514678&r2=514679
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/FavoriteUsingSpringTest.java
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/FavoriteUsingSpringTest.java
Mon Mar  5 06:44:24 2007
@@ -16,6 +16,7 @@
  */
 package org.apache.xbean.spring.context;
 
+import java.util.List;
 import java.util.Map;
 
 import org.springframework.context.support.AbstractXmlApplicationContext;
@@ -33,9 +34,14 @@
   
         Map favorites = fs.getFavorites();
         assertNotNull(favorites);
-        assertEquals(1, favorites.size());
+        assertEquals(2, favorites.size());
         
         assertEquals("Grey Goose", favorites.get("Dan"));
+        Object object = favorites.get("IndecisiveDan");
+        System.out.println(object.getClass());
+        assertTrue(object instanceof List);
+        List l = (List) object;
+        assertEquals(2, l.size());
     }
 
     protected AbstractXmlApplicationContext createApplicationContext() {

Modified: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/favorite-normal.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/favorite-normal.xml?view=diff&rev=514679&r1=514678&r2=514679
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/favorite-normal.xml
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/favorite-normal.xml
Mon Mar  5 06:44:24 2007
@@ -22,11 +22,17 @@
 
   <bean id="favoriteService" class="org.apache.xbean.spring.example.FavoriteService">
     <property name="favorites"> 
-        <map> 
-         <entry key="Dan">
-           <value>Grey Goose</value>
-         </entry>
-        </map>
+      <map> 
+        <entry key="Dan">
+          <value>Grey Goose</value>
+        </entry>
+        <entry key="IndecisiveDan">
+          <list>
+            <value>Malbec</value>
+            <value>Cognac</value>
+          </list>
+        </entry>
+      </map>
     </property>
   </bean>
 

Modified: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/favorite-xbean.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/favorite-xbean.xml?view=diff&rev=514679&r1=514678&r2=514679
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/favorite-xbean.xml
(original)
+++ geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/favorite-xbean.xml
Mon Mar  5 06:44:24 2007
@@ -22,7 +22,13 @@
 
   <b:favorite s:id="favoriteService">
     <b:favorites>
-      <b:favorite-item person="Dan">Grey Goose</b:favorite-item>
+      <b:favorite-item person="Dan">Grey Goose</b:favorite-item>
+      <b:favorite-item person="IndecisiveDan">
+        <list>
+          <value>Malbec</value>
+          <value>Cognac</value>
+        </list>
+      </b:favorite-item>
     </b:favorites>
   </b:favorite>
 



Mime
View raw message