RESOLVED - issue BATCH-1370: Bind to non-scalar map entry values in step scope

Also fixed: no need to use custom PropertyEditor to bind to Dates from step context
This commit is contained in:
dsyer
2009-08-14 09:35:50 +00:00
parent 0bf64b4a80
commit 7c487a7abc
7 changed files with 330 additions and 104 deletions

View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p" 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.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean id="context"
class="org.springframework.batch.core.scope.util.PlaceholderTargetSourceCustomEditorTests" />
<bean id="withEmbeddedDate"
class="org.springframework.batch.core.scope.util.PlaceholderTargetSource">
<property name="contextFactory" ref="context" />
<property name="targetBeanName" value="withEmbeddedDateTarget" />
</bean>
<bean id="withEmbeddedDateTarget"
class="org.springframework.batch.core.scope.util.PlaceholderTargetSourceCustomEditorTests$Foo"
lazy-init="true">
<property name="name" value="bar-%{date}" />
</bean>
<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="propertyEditorRegistrars">
<bean
class="org.springframework.batch.support.DefaultPropertyEditorRegistrar">
<property name="customEditors">
<map>
<entry key="java.util.Date">
<bean
class="org.springframework.beans.propertyeditors.CustomDateEditor">
<constructor-arg>
<bean class="java.text.SimpleDateFormat">
<constructor-arg value="yyyy/MM/dd" />
</bean>
</constructor-arg>
<constructor-arg value="false" />
</bean>
</entry>
</map>
</property>
</bean>
</property>
</bean>
</beans>

View File

@@ -58,6 +58,18 @@
<property name="targetBeanName" value="withListTarget" />
</bean>
<bean id="withLiteralList"
class="org.springframework.batch.core.scope.util.PlaceholderTargetSource">
<property name="contextFactory" ref="context" />
<property name="targetBeanName" value="withLiteralListTarget" />
</bean>
<bean id="withMap"
class="org.springframework.batch.core.scope.util.PlaceholderTargetSource">
<property name="contextFactory" ref="context" />
<property name="targetBeanName" value="withMapTarget" />
</bean>
<bean id="withMultiple"
class="org.springframework.batch.core.scope.util.PlaceholderTargetSource">
<property name="contextFactory" ref="context" />
@@ -135,6 +147,24 @@
</property>
</bean>
<bean id="withLiteralListTarget"
class="org.springframework.batch.core.scope.util.PlaceholderTargetSourceTests$Foo"
lazy-init="true">
<property name="list" value="%{list}"/>
</bean>
<bean id="withMapTarget"
class="org.springframework.batch.core.scope.util.PlaceholderTargetSourceTests$Foo"
lazy-init="true">
<property name="map">
<map value-type="java.lang.Object">
<entry key="foo" value="%{foo}"/>
<entry key="bar" value="foo-%{integer}"/>
<entry key="spam" value="%{list}"/>
</map>
</property>
</bean>
<bean id="withMultipleTarget"
class="org.springframework.batch.core.scope.util.PlaceholderTargetSourceTests$Foo"
lazy-init="true">
@@ -159,27 +189,4 @@
<property name="date" value="%{date}" />
</bean>
<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="propertyEditorRegistrars">
<bean
class="org.springframework.batch.support.DefaultPropertyEditorRegistrar">
<property name="customEditors">
<map>
<entry key="java.util.Date">
<bean
class="org.springframework.beans.propertyeditors.CustomDateEditor">
<constructor-arg>
<bean class="java.text.SimpleDateFormat">
<constructor-arg value="yyyy/MM/dd" />
</bean>
</constructor-arg>
<constructor-arg value="false" />
</bean>
</entry>
</map>
</property>
</bean>
</property>
</bean>
</beans>