Add value-type attrib to beans->map->entry element

Previously, the <value> subelement of a map <entry> allowed one to
specify the type of a specific map entry value. This patch allows a
value-type attribute as well, such that instead of the following
syntax

    <entry key="x-message-ttl">
        <value type="java.lang.Long">100</value>
    </entry>
    <entry key="x-ha-policy" value="all" />

one can now use the more concise form

    <entry key="x-message-ttl" value="100" value-type="java.lang.Long"/>
    <entry key="x-ha-policy" value="all"/>

The new value-type attribute may be used at the <map> level as well,
indicating that all elements are of the same type.

Appropriate tests have been added exercising value-type at the <map> and
<entry> levels.

Issue: SPR-9249
This commit is contained in:
Gary Russell
2012-03-19 19:59:10 -04:00
committed by Chris Beams
parent f3bcb6e2e4
commit 183ac0c1ff
4 changed files with 31 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
<bean id="jenny" class="test.beans.TestBean">
<property name="name"><value>Jenny</value></property>
@@ -133,7 +133,7 @@
<bean id="mixedMap" class="org.springframework.beans.factory.xml.HasMap">
<property name="map">
<map>
<map value-type="java.lang.Integer">
<entry key-ref="fooKey">
<value type="java.lang.Integer">10</value>
</entry>
@@ -151,6 +151,8 @@
</key>
<idref bean="david"/>
</entry>
<entry key="bar" value="100" value-type="java.lang.Long"/>
<entry key="baz" value="200"/>
</map>
</property>
</bean>