[jboss-cvs] JBossAS SVN: r60133 - in projects/microcontainer/trunk/spring-int/src: resources/schema and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 31 08:09:53 EST 2007
Author: alesj
Date: 2007-01-31 08:09:53 -0500 (Wed, 31 Jan 2007)
New Revision: 60133
Added:
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringPlainValueHandler.java
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/StringEntryValueInterceptor.java
Modified:
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeansInterceptor.java
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBinding.java
projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBindingHelper.java
projects/microcontainer/trunk/spring-int/src/resources/schema/mc-spring-beans_2_0.xsd
projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateMixed2TestCase.xml
projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateSpringTestCase.xml
projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/TestDescribe.xml
Log:
Fixing Map handling; special plain string value handling.
Modified: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeansInterceptor.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeansInterceptor.java 2007-01-31 12:43:12 UTC (rev 60132)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringBeansInterceptor.java 2007-01-31 13:09:53 UTC (rev 60133)
@@ -21,15 +21,15 @@
*/
package org.jboss.spring.deployment.xml;
-import javax.xml.namespace.QName;
-
import java.util.ArrayList;
import java.util.List;
+import javax.xml.namespace.QName;
-import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
import org.jboss.spring.metadata.AbstractSpringDeployment;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
/**
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
@@ -43,24 +43,30 @@
public void add(Object parent, Object child, QName name)
{
- AbstractSpringDeployment deployment = (AbstractSpringDeployment) parent;
- AbstractBeanMetaData bean = (AbstractBeanMetaData) child;
+ AbstractKernelDeployment deployment = (AbstractKernelDeployment)parent;
+ AbstractBeanMetaData bean = (AbstractBeanMetaData)child;
List<BeanMetaDataFactory> beans = deployment.getBeanFactories();
if (beans == null)
{
beans = new ArrayList<BeanMetaDataFactory>();
deployment.setBeanFactories(beans);
}
- // set deployment defaults, if not already set per bean
- if (bean.getCreate() == null && deployment.getCreate() != null)
+ beans.add(bean);
+
+ // handle bean lifecycle
+ if (deployment instanceof AbstractSpringDeployment)
{
- bean.setCreate(deployment.getCreate());
+ AbstractSpringDeployment sd = (AbstractSpringDeployment)deployment;
+ // set deployment defaults, if not already set per bean
+ if (bean.getCreate() == null && sd.getCreate() != null)
+ {
+ bean.setCreate(sd.getCreate());
+ }
+ if (bean.getDestroy() == null && sd.getDestroy() != null)
+ {
+ bean.setDestroy(sd.getDestroy());
+ }
}
- if (bean.getDestroy() == null && deployment.getDestroy() != null)
- {
- bean.setDestroy(deployment.getDestroy());
- }
- beans.add(bean);
}
}
Added: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringPlainValueHandler.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringPlainValueHandler.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringPlainValueHandler.java 2007-01-31 13:09:53 UTC (rev 60133)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.spring.deployment.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.StringValueMetaData;
+import org.jboss.kernel.plugins.deployment.xml.PlainValueHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
+
+/**
+ * Spring has type insted of class attribute.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SpringPlainValueHandler extends PlainValueHandler
+{
+ /** The interceptor */
+ public static final SpringPlainValueHandler HANDLER = new SpringPlainValueHandler();
+
+ public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+ {
+ StringValueMetaData value = (StringValueMetaData) o;
+ for (int i = 0; i < attrs.getLength(); ++i)
+ {
+ String localName = attrs.getLocalName(i);
+ if ("type".equals(localName))
+ value.setType(attrs.getValue(i));
+ }
+ }
+}
Modified: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBinding.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBinding.java 2007-01-31 12:43:12 UTC (rev 60132)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBinding.java 2007-01-31 13:09:53 UTC (rev 60133)
@@ -105,7 +105,7 @@
/**
* The list binding
*/
- public static final QName listOrSetTypeQName = new QName(SPRING_DEPLOYER_NS, "listOrSetType");
+ public static final QName listTypeQName = new QName(SPRING_DEPLOYER_NS, "listType");
/**
* The list element name
@@ -113,6 +113,11 @@
public static final QName listQName = new QName(SPRING_DEPLOYER_NS, "list");
/**
+ * The set binding
+ */
+ public static final QName setTypeQName = new QName(SPRING_DEPLOYER_NS, "setType");
+
+ /**
* The set element name
*/
public static final QName setQName = new QName(SPRING_DEPLOYER_NS, "set");
@@ -224,10 +229,14 @@
TypeBinding valueType = schemaBinding.getType(valueTypeQName);
SpringSchemaBindingHelper.initValueHandler(valueType);
- // list or set
- TypeBinding collectionType = schemaBinding.getType(listOrSetTypeQName);
- SpringSchemaBindingHelper.initCollectionHandler(collectionType);
+ // list
+ TypeBinding listType = schemaBinding.getType(listTypeQName);
+ SpringSchemaBindingHelper.initCollectionHandler(listType);
+ // set
+ TypeBinding setType = schemaBinding.getType(setTypeQName);
+ SpringSchemaBindingHelper.initCollectionHandler(setType);
+
// map
TypeBinding mapType = schemaBinding.getType(mapTypeQName);
SpringSchemaBindingHelper.initMapHandler(mapType);
@@ -237,7 +246,7 @@
SpringSchemaBindingHelper.initEntryHandler(entryType);
// key type
- TypeBinding keyType = schemaBinding.getType(entryTypeQName);
+ TypeBinding keyType = schemaBinding.getType(keyTypeQName);
SpringSchemaBindingHelper.initKeyHandler(keyType);
// props
Modified: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBindingHelper.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBindingHelper.java 2007-01-31 12:43:12 UTC (rev 60132)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/SpringSchemaBindingHelper.java 2007-01-31 13:09:53 UTC (rev 60133)
@@ -21,7 +21,18 @@
*/
package org.jboss.spring.deployment.xml;
-import org.jboss.kernel.plugins.deployment.xml.*;
+import org.jboss.kernel.plugins.deployment.xml.BeanPropertyInterceptor;
+import org.jboss.kernel.plugins.deployment.xml.EntryHandler;
+import org.jboss.kernel.plugins.deployment.xml.EntryKeyInterceptor;
+import org.jboss.kernel.plugins.deployment.xml.EntryValueInterceptor;
+import org.jboss.kernel.plugins.deployment.xml.MapEntryInterceptor;
+import org.jboss.kernel.plugins.deployment.xml.NullValueElementInterceptor;
+import org.jboss.kernel.plugins.deployment.xml.PlainValueCharactersHandler;
+import org.jboss.kernel.plugins.deployment.xml.PropHandler;
+import org.jboss.kernel.plugins.deployment.xml.PropertiesHandler;
+import org.jboss.kernel.plugins.deployment.xml.PropertyCharactersHandler;
+import org.jboss.kernel.plugins.deployment.xml.PropertyHandler;
+import org.jboss.kernel.plugins.deployment.xml.ValueMetaDataElementInterceptor;
import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
/**
@@ -74,7 +85,7 @@
// here value only takes simple type
public static void initValueHandler(TypeBinding typeBinding)
{
- typeBinding.setHandler(PlainValueHandler.HANDLER);
+ typeBinding.setHandler(SpringPlainValueHandler.HANDLER);
// value can take characters
typeBinding.setSimpleType(PlainValueCharactersHandler.HANDLER);
}
@@ -114,7 +125,7 @@
typeBinding.pushInterceptor(SpringSchemaBinding.refQName, EntryValueInterceptor.INTERCEPTOR);
// entry has value
- typeBinding.pushInterceptor(SpringSchemaBinding.valueQName, EntryValueInterceptor.INTERCEPTOR);
+ typeBinding.pushInterceptor(SpringSchemaBinding.valueQName, StringEntryValueInterceptor.INTERCEPTOR);
// entry can take a list
typeBinding.pushInterceptor(SpringSchemaBinding.listQName, EntryValueInterceptor.INTERCEPTOR);
Added: projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/StringEntryValueInterceptor.java
===================================================================
--- projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/StringEntryValueInterceptor.java (rev 0)
+++ projects/microcontainer/trunk/spring-int/src/main/org/jboss/spring/deployment/xml/StringEntryValueInterceptor.java 2007-01-31 13:09:53 UTC (rev 60133)
@@ -0,0 +1,44 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.spring.deployment.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
+import org.jboss.kernel.plugins.deployment.xml.EntryValueInterceptor;
+
+/**
+ * Spring only handles plain string value.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class StringEntryValueInterceptor extends EntryValueInterceptor
+{
+ /** The interceptor */
+ public static final StringEntryValueInterceptor INTERCEPTOR = new StringEntryValueInterceptor();
+
+ public void add(Object parent, Object child, QName name)
+ {
+ AbstractValueMetaData avmd = new AbstractValueMetaData(child);
+ super.add(parent, avmd, name);
+ }
+}
Modified: projects/microcontainer/trunk/spring-int/src/resources/schema/mc-spring-beans_2_0.xsd
===================================================================
--- projects/microcontainer/trunk/spring-int/src/resources/schema/mc-spring-beans_2_0.xsd 2007-01-31 12:43:12 UTC (rev 60132)
+++ projects/microcontainer/trunk/spring-int/src/resources/schema/mc-spring-beans_2_0.xsd 2007-01-31 13:09:53 UTC (rev 60133)
@@ -596,9 +596,8 @@
<xsd:element name="idref" type="idrefType"/>
<xsd:element name="value" type="valueType"/>
<xsd:element name="null" type="nullType"/>
- <xsd:element name="list" type="listOrSetType"/>
- <xsd:element name="set" type="listOrSetType"/>
-
+ <xsd:element name="list" type="listType"/>
+ <xsd:element name="set" type="setType"/>
<xsd:element name="map" type="mapType"/>
<xsd:element name="props" type="propsType"/>
<xsd:any namespace="##other" processContents="strict"/>
@@ -895,8 +894,8 @@
<xsd:element name="idref" type="idrefType"/>
<xsd:element name="value" type="valueType"/>
<xsd:element name="null" type="nullType"/>
- <xsd:element name="list" type="listOrSetType"/>
- <xsd:element name="set" type="listOrSetType"/>
+ <xsd:element name="list" type="listType"/>
+ <xsd:element name="set" type="setType"/>
<xsd:element name="map" type="mapType"/>
<xsd:element name="props" type="propsType"/>
<xsd:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="unbounded"/>
@@ -905,7 +904,7 @@
</xsd:group>
- <xsd:element name="list" type="listOrSetType">
+ <xsd:element name="list" type="listType">
<xsd:annotation>
<xsd:documentation><![CDATA[
A list can contain multiple inner bean, ref, collection, or value
@@ -916,7 +915,7 @@
]]></xsd:documentation>
</xsd:annotation>
</xsd:element>
- <xsd:element name="set" type="listOrSetType">
+ <xsd:element name="set" type="setType">
<xsd:annotation>
<xsd:documentation><![CDATA[
@@ -987,7 +986,6 @@
<xsd:complexType name="propertyType">
<xsd:sequence>
<xsd:element name="description" type="descriptionType" minOccurs="0"/>
-
<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:element name="meta" type="metaType"/>
<xsd:element name="bean" type="beanType"/>
@@ -995,8 +993,8 @@
<xsd:element name="idref" type="idrefType"/>
<xsd:element name="value" type="valueType"/>
<xsd:element name="null" type="nullType"/>
- <xsd:element name="list" type="listOrSetType"/>
- <xsd:element name="set" type="listOrSetType"/>
+ <xsd:element name="list" type="listType"/>
+ <xsd:element name="set" type="setType"/>
<xsd:element name="map" type="mapType"/>
<xsd:element name="props" type="propsType"/>
<xsd:any namespace="##other" processContents="strict"/>
@@ -1032,6 +1030,9 @@
<!-- base collection type -->
<xsd:complexType name="baseCollectionType">
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:group ref="collectionElements"/>
+ </xsd:choice>
<xsd:attribute name="merge" type="defaultable-boolean">
<xsd:annotation>
@@ -1040,9 +1041,10 @@
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
+ <xsd:attribute name="value-type" type="xsd:string" use="optional"/>
</xsd:complexType>
- <!-- base type for collections that have (possibly) typed nested values -->
+ <!-- base type for collections that have (possibly) typed nested values
<xsd:complexType name="typedCollectionType">
<xsd:complexContent>
<xsd:extension base="baseCollectionType">
@@ -1058,11 +1060,20 @@
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
+ -->
<!-- 'map' element type -->
<xsd:complexType name="mapType">
+ <xsd:sequence>
+ <xsd:element name="entry" type="entryType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="key-type" type="xsd:string" use="optional"/>
+ </xsd:complexType>
+
+<!--
+ <xsd:complexType name="mapType">
<xsd:complexContent>
- <xsd:extension base="typedCollectionType">
+ <xsd:extension base="baseCollectionType">
<xsd:sequence>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="entry" type="entryType"/>
@@ -1080,12 +1091,13 @@
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
+-->
<!-- 'entry' element type -->
<xsd:complexType name="entryType">
<xsd:sequence>
<xsd:element name="key" type="keyType" minOccurs="0"/>
- <xsd:group ref="collectionElements"/>
+ <xsd:group ref="collectionElements" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="key" type="xsd:string">
<xsd:annotation>
@@ -1106,7 +1118,6 @@
</xsd:attribute>
<xsd:attribute name="value" type="xsd:string">
<xsd:annotation>
-
<xsd:documentation><![CDATA[
A short-cut alternative to a nested "<value>...</value>"
element.
@@ -1123,14 +1134,18 @@
</xsd:complexType>
<!-- 'list' and 'set' collection type -->
- <xsd:complexType name="listOrSetType">
+ <xsd:complexType name="listType">
<xsd:complexContent>
- <xsd:extension base="typedCollectionType">
- <xsd:group ref="collectionElements"/>
- </xsd:extension>
+ <xsd:extension base="baseCollectionType" />
</xsd:complexContent>
</xsd:complexType>
+ <xsd:complexType name="setType">
+ <xsd:complexContent>
+ <xsd:extension base="baseCollectionType" />
+ </xsd:complexContent>
+ </xsd:complexType>
+
<!-- 'props' collection type -->
<xsd:complexType name="propsType">
<xsd:complexContent>
@@ -1139,7 +1154,6 @@
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="prop" type="propType"/>
</xsd:choice>
-
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
Modified: projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateMixed2TestCase.xml
===================================================================
--- projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateMixed2TestCase.xml 2007-01-31 12:43:12 UTC (rev 60132)
+++ projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateMixed2TestCase.xml 2007-01-31 13:09:53 UTC (rev 60133)
@@ -7,7 +7,7 @@
</bean>
<bean xmlns="urn:jboss:bean-deployer:2.0" name="oldBean" class="org.jboss.test.spring.support.OldBean">
- <property name="javaBeanString">JavaBean</property>
+ <property name="javaBeanString"><value>JavaBean</value></property>
</bean>
</beans>
\ No newline at end of file
Modified: projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateSpringTestCase.xml
===================================================================
--- projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateSpringTestCase.xml 2007-01-31 12:43:12 UTC (rev 60132)
+++ projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/InstantiateSpringTestCase.xml 2007-01-31 13:09:53 UTC (rev 60133)
@@ -26,16 +26,16 @@
<value>ones</value>
</set>
</property>
- <!--
- <property name="map">
+ <property name="mymap">
+ <map key-type="java.lang.String">
<entry>
<key>
<value>test_key</value>
</key>
- <value>myvalue</value>
+ <value type="java.lang.String">myvalue</value>
</entry>
- </property>
- -->
+ </map>
+ </property>
</bean>
</beans>
\ No newline at end of file
Modified: projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/TestDescribe.xml
===================================================================
--- projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/TestDescribe.xml 2007-01-31 12:43:12 UTC (rev 60132)
+++ projects/microcontainer/trunk/spring-int/src/resources/xml-test/org/jboss/test/spring/test/TestDescribe.xml 2007-01-31 13:09:53 UTC (rev 60133)
@@ -1,9 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
-<bean xmlns="urn:jboss:spring-beans:2.0" id="testBean" class="org.jboss.test.spring.support.SimpleBean" >
- <constructor-arg index="2"><value>SpringBean</value></constructor-arg>
- <constructor-arg index="0"><value>1</value></constructor-arg>
- <constructor-arg index="1"><value>3.14159</value></constructor-arg>
+<bean xmlns="urn:jboss:spring-beans:2.0" id="testBean" class="org.jboss.test.spring.support.SimpleBean">
+ <constructor-arg index="2">
+ <value>SpringBean</value>
+ </constructor-arg>
+ <constructor-arg index="0">
+ <value>1</value>
+ </constructor-arg>
+ <constructor-arg index="1">
+ <value>3.14159</value>
+ </constructor-arg>
<property name="mylist">
<list value-type="java.lang.String">
<value>onel</value>
@@ -18,12 +24,14 @@
<value>ones</value>
</set>
</property>
- <property name="map">
- <entry>
- <key>
- <value>test_key</value>
- </key>
- <value>myvalue</value>
- </entry>
+ <property name="mymap">
+ <map>
+ <entry>
+ <key>
+ <value>test_key</value>
+ </key>
+ <value>myvalue</value>
+ </entry>
+ </map>
</property>
</bean>
More information about the jboss-cvs-commits
mailing list