You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xbean-scm@geronimo.apache.org by ch...@apache.org on 2008/01/09 14:31:39 UTC

svn commit: r610381 - 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/

Author: chirino
Date: Wed Jan  9 05:31:08 2008
New Revision: 610381

URL: http://svn.apache.org/viewvc?rev=610381&view=rev
Log:
Test case and fix for https://issues.apache.org/jira/browse/XBEAN-101
- a PropertyPlaceholderConfigurer could not be used to resolve values assigned to xbean properties that have a custom PropertyEditor


Added:
    geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/v2c/PropertyEditorFactory.java   (with props)
    geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/KegXBeanAndPropertiesTest.java   (with props)
    geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/keg-xbean-properties.properties   (with props)
    geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/keg-xbean-properties.xml   (with props)
Modified:
    geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/v2c/XBeanNamespaceHandler.java

Added: geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/v2c/PropertyEditorFactory.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/v2c/PropertyEditorFactory.java?rev=610381&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/v2c/PropertyEditorFactory.java (added)
+++ geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/v2c/PropertyEditorFactory.java Wed Jan  9 05:31:08 2008
@@ -0,0 +1,65 @@
+/**
+ * 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.v2c;
+
+import java.beans.PropertyEditor;
+import org.springframework.beans.factory.FactoryBean;
+
+public class PropertyEditorFactory implements FactoryBean {
+
+	PropertyEditor propertyEditor;
+	String value;
+	Class type = Object.class;
+	
+	public Object getObject() throws Exception {
+		propertyEditor.setAsText(value);
+    	return propertyEditor.getValue();		
+	}
+
+	public Class getObjectType() {
+		return type;
+	}
+
+	public boolean isSingleton() {
+		return true;
+	}
+
+	public String getValue() {
+		return value;
+	}
+
+	public void setValue(String value) {
+		this.value = value;
+	}
+
+	public PropertyEditor getPropertyEditor() {
+		return propertyEditor;
+	}
+
+	public void setPropertyEditor(PropertyEditor propertyEditor) {
+		this.propertyEditor = propertyEditor;
+	}
+
+	public Class getType() {
+		return type;
+	}
+
+	public void setType(Class type) {
+		this.type = type;
+	}
+
+}

Propchange: geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/v2c/PropertyEditorFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-spring/src/main/java/org/apache/xbean/spring/context/v2c/PropertyEditorFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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=610381&r1=610380&r2=610381&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 Wed Jan  9 05:31:08 2008
@@ -50,9 +50,11 @@
 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;
+import org.springframework.beans.factory.support.RootBeanDefinition;
 import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
 import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
 import org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader;
@@ -428,8 +430,13 @@
 
         if( propertyEditor!=null ) {
         	PropertyEditor p = createPropertyEditor(propertyEditor);
-        	p.setAsText(value);
-        	return p.getValue();
+        	
+        	RootBeanDefinition def = new RootBeanDefinition();
+        	def.setBeanClass(PropertyEditorFactory.class);
+        	def.getPropertyValues().addPropertyValue("propertyEditor", p);
+        	def.getPropertyValues().addPropertyValue("value", value);
+        	
+        	return def;
         }
         
         //

Added: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/KegXBeanAndPropertiesTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/KegXBeanAndPropertiesTest.java?rev=610381&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/KegXBeanAndPropertiesTest.java (added)
+++ geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/KegXBeanAndPropertiesTest.java Wed Jan  9 05:31:08 2008
@@ -0,0 +1,36 @@
+/**
+ * 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.apache.xbean.spring.example.KegService;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+/**
+ * Used to verify that per Property Editors work correctly with
+ * a PropertyPlaceholderConfigurer used to configure the values.
+ * 
+ * @author chirino
+ * @version $Id$
+ * @since 2.2
+ */
+public class KegXBeanAndPropertiesTest extends KegXBeanTest {
+
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/xbean/spring/context/keg-xbean-properties.xml");
+    }
+
+}

Propchange: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/KegXBeanAndPropertiesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-spring/src/test/java/org/apache/xbean/spring/context/KegXBeanAndPropertiesTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/keg-xbean-properties.properties
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/keg-xbean-properties.properties?rev=610381&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/keg-xbean-properties.properties (added)
+++ geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/keg-xbean-properties.properties Wed Jan  9 05:31:08 2008
@@ -0,0 +1,4 @@
+  ml1000=1000 ml
+  pints5=5 pints
+  liter20=20 liter
+  empty=0
\ No newline at end of file

Propchange: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/keg-xbean-properties.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/keg-xbean-properties.properties
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/keg-xbean-properties.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/keg-xbean-properties.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/keg-xbean-properties.xml?rev=610381&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/keg-xbean-properties.xml (added)
+++ geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/keg-xbean-properties.xml Wed Jan  9 05:31:08 2008
@@ -0,0 +1,33 @@
+<?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.
+
+-->
+<!-- START SNIPPET: xml -->
+<beans xmlns:x="http://xbean.apache.org/schemas/pizza">
+
+  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+	<property name="location" value="org/apache/xbean/spring/context/keg-xbean-properties.properties" />
+  </bean>  
+	  
+  <x:keg id="ml1000" remaining="${ml1000}"/>
+  <x:keg id="pints5" remaining="${pints5}"/>
+  <x:keg id="liter20" remaining="${liter20}"/>
+  <x:keg id="empty" remaining="${empty}"/>
+
+</beans>
+<!-- END SNIPPET: xml -->

Propchange: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/keg-xbean-properties.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/keg-xbean-properties.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: geronimo/xbean/trunk/xbean-spring/src/test/resources/org/apache/xbean/spring/context/keg-xbean-properties.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml