geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r671823 - 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 Thu, 26 Jun 2008 08:40:35 GMT
Author: gnodet
Date: Thu Jun 26 01:40:34 2008
New Revision: 671823

URL: http://svn.apache.org/viewvc?rev=671823&view=rev
Log:
XBEAN-107: Problems with nested <property/> elements when they are in the spring namespace

Added:
    geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/RecipeUsingXBeanMixedTest.java
    geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/recipe-xbean-mixed.xml
Modified:
    geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/v2c/XBeanNamespaceHandler.java

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?rev=671823&r1=671822&r2=671823&view=diff
==============================================================================
--- 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
Thu Jun 26 01:40:34 2008
@@ -41,7 +41,6 @@
 import org.apache.xbean.spring.context.impl.MappingMetaData;
 import org.apache.xbean.spring.context.impl.NamedConstructorArgs;
 import org.apache.xbean.spring.context.impl.NamespaceHelper;
-import org.apache.xbean.spring.context.impl.PropertyEditorHelper;
 import org.springframework.beans.PropertyValue;
 import org.springframework.beans.PropertyEditorRegistrar;
 import org.springframework.beans.PropertyEditorRegistry;
@@ -52,7 +51,6 @@
 import org.springframework.beans.factory.parsing.BeanComponentDefinition;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
 import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
-import org.springframework.beans.factory.support.ChildBeanDefinition;
 import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 import org.springframework.beans.factory.support.ManagedList;
 import org.springframework.beans.factory.support.ManagedMap;
@@ -64,6 +62,8 @@
 import org.springframework.beans.factory.xml.ParserContext;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.util.StringUtils;
+
 import org.w3c.dom.Attr;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
@@ -488,7 +488,7 @@
                 String uri = childElement.getNamespaceURI();
                 String localName = childElement.getLocalName();
 
-                if (!isEmpty(uri) || !reservedElementNames.contains(localName)) {
+                if (!isDefaultNamespace(uri) || !reservedElementNames.contains(localName))
{
                     // we could be one of the following
                     // * the child element maps to a <property> tag with inner
                     // tags being the bean
@@ -847,6 +847,13 @@
         return uri == null || uri.length() == 0;
     }
 
+    protected boolean isDefaultNamespace(String namespaceUri) {
+        return (!StringUtils.hasLength(namespaceUri) ||
+               BeanDefinitionParserDelegate.BEANS_NAMESPACE_URI.equals(namespaceUri)) ||
+               SPRING_SCHEMA.equals(namespaceUri) ||
+               SPRING_SCHEMA_COMPAT.equals(namespaceUri);
+    }
+
     protected void declareLifecycleMethods(BeanDefinitionHolder definitionHolder, MappingMetaData
metaData,
             Element element) {
         BeanDefinition definition = definitionHolder.getBeanDefinition();

Added: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/RecipeUsingXBeanMixedTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/RecipeUsingXBeanMixedTest.java?rev=671823&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/RecipeUsingXBeanMixedTest.java
(added)
+++ geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/RecipeUsingXBeanMixedTest.java
Thu Jun 26 01:40:34 2008
@@ -0,0 +1,27 @@
+/**
+ * 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.xbean.spring.context;
+
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+public class RecipeUsingXBeanMixedTest extends RecipeUsingSpringTest {
+
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/xbean/spring/context/recipe-xbean-mixed.xml");
+    }
+
+}

Added: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/recipe-xbean-mixed.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/recipe-xbean-mixed.xml?rev=671823&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/recipe-xbean-mixed.xml
(added)
+++ geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/recipe-xbean-mixed.xml
Thu Jun 26 01:40:34 2008
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<beans xmlns:x="http://xbean.apache.org/schemas/pizza" xmlns:foo="urn:foo">
+
+  <x:recipe-service id="recipeService">
+    <property name="topRecipe" xmlns="http://www.springframework.org/schema/beans">

+      <bean class="org.apache.xbean.spring.example.Recipe">
+        <property name="instructions" value="Mash together" />
+        <property name="ingredients" value="Food" />
+      </bean>
+    </property>
+    <x:recipe>
+      <x:instructions>Mash together</x:instructions>
+      <x:ingredients>Food</x:ingredients>
+    </x:recipe>
+    <x:recipe>
+      <x:instructions>Mash together</x:instructions>
+      <x:ingredients>Food</x:ingredients>
+    </x:recipe>
+  </x:recipe-service>
+
+</beans>



Mime
View raw message