Fixed all but restart sample (left unscoped file input). But see SPR-3804 for problems that have to be worked around.

Open: BATCH-114: Samples broken when input/output sources have step scope (http://opensource.atlassian.com/projects/spring-17738)
This commit is contained in:
dsyer
2007-08-28 07:16:33 +00:00
parent d7444bbc95
commit 6f75f99903
11 changed files with 801 additions and 741 deletions

View File

@@ -1,131 +1,135 @@
<?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-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry"/>
</bean>
<bean id="jobConfiguration" parent="simpleJob" p:name="beanWrapperMapperSampleJob">
<property name="steps">
<list>
<bean id="step1" parent="simpleStep">
<constructor-arg>
<bean
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean
class="org.springframework.batch.item.provider.FlatFileItemProvider">
<property name="source" ref="fileInputTemplate" />
<property name="mapper" ref="fieldSetMapper" />
<property name="validator" ref="fixedValidator" />
</bean>
</property>
<property name="itemProcessor">
<bean class="org.springframework.batch.sample.module.process.TradeProcessor">
<property name="writer" ref="tradeDao" />
</bean>
</property>
</bean>
</constructor-arg>
</bean>
<bean id="step2" parent="simpleStep">
<constructor-arg>
<bean
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean
class="org.springframework.batch.item.provider.FlatFileItemProvider">
<property name="source" ref="fileInputTemplate2" />
<property name="mapper" ref="fieldSetMapper2" />
</bean>
</property>
<property name="itemProcessor">
<bean class="org.springframework.batch.sample.module.process.PersonProcessor" />
</property>
</bean>
</constructor-arg>
</bean>
</list>
</property>
</bean>
<!-- INFRASTRUCTURE SETUP -->
<bean id="fileInputTemplate" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource">
<property name="resource" ref="fileLocator" />
<property name="tokenizer" ref="fixedFileDescriptor" />
</bean>
<bean id="fileInputTemplate2" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource">
<property name="resource" ref="fileLocator2" />
<property name="tokenizer" ref="fixedFileDescriptor2" />
<!-- <property name="validator" ref="fixedValidator" />-->
</bean>
<bean id="fixedFileDescriptor"
class="org.springframework.batch.io.file.support.transform.FixedLengthTokenizer">
<property name="names" value="ISIN,Quantity,price, CUSTOMER" />
<property name="lengths" value="12, 3, 5, 9" />
</bean>
<bean id="fixedFileDescriptor2"
class="org.springframework.batch.io.file.support.transform.FixedLengthTokenizer">
<property name="names" value="Title, FirstName, LastName, Age, Address.AddrLine1, children[0].name, children[1].name" />
<property name="lengths" value="5, 15, 20, 5, 10, 10, 10" />
</bean>
<bean id="fixedValidator" class="org.springframework.batch.item.validator.SpringValidator">
<property name="validator">
<bean id="tradeValidator" class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value>
<![CDATA[
{ isin : length(?) < 13 : 'ISIN too long' : 'isin_length' : 12}
]]>
</value>
</property>
</bean>
</property>
</bean>
<bean id="tradeDao" class="org.springframework.batch.sample.dao.JdbcTradeWriter">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="incrementer">
<bean parent="incrementerParent">
<property name="incrementerName" value="TRADE_SEQ" />
</bean>
</property>
</bean>
<bean id="fileLocator" class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String"
value="data/beanWrapperMapperSampleJob/input/20070122.teststream.ImportTradeDataStep.txt" />
</bean>
<bean id="fileLocator2" class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String"
value="data/beanWrapperMapperSampleJob/input/20070122.teststream.ImportPersonDataStep.txt" />
</bean>
<bean id="fieldSetMapper" class="org.springframework.batch.io.file.support.mapping.BeanWrapperFieldSetMapper">
<property name="prototypeBeanName" value="trade"/>
</bean>
<bean id="fieldSetMapper2" class="org.springframework.batch.io.file.support.mapping.BeanWrapperFieldSetMapper">
<property name="prototypeBeanName" value="person"/>
</bean>
<bean id="trade" class="org.springframework.batch.sample.domain.Trade" scope="prototype"/>
<bean id="person" class="org.springframework.batch.sample.domain.Person" scope="prototype"/>
</beans>
<?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-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry"/>
</bean>
<bean id="jobConfiguration" parent="simpleJob" p:name="beanWrapperMapperSampleJob">
<property name="steps">
<list>
<bean id="step1" parent="simpleStep">
<constructor-arg>
<bean
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean
class="org.springframework.batch.item.provider.FlatFileItemProvider">
<property name="source" ref="fileInputTemplate" />
<property name="mapper" ref="fieldSetMapper" />
<property name="validator" ref="fixedValidator" />
</bean>
</property>
<property name="itemProcessor">
<bean class="org.springframework.batch.sample.module.process.TradeProcessor">
<property name="writer" ref="tradeDao" />
</bean>
</property>
</bean>
</constructor-arg>
</bean>
<bean id="step2" parent="simpleStep">
<constructor-arg>
<bean
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean
class="org.springframework.batch.item.provider.FlatFileItemProvider">
<property name="source" ref="fileInputTemplate2" />
<property name="mapper" ref="fieldSetMapper2" />
</bean>
</property>
<property name="itemProcessor">
<bean class="org.springframework.batch.sample.module.process.PersonProcessor" />
</property>
</bean>
</constructor-arg>
</bean>
</list>
</property>
</bean>
<!-- INFRASTRUCTURE SETUP -->
<bean id="fileInputTemplate" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource"
scope="step" >
<aop:scoped-proxy />
<property name="resource" ref="fileLocator" />
<property name="tokenizer" ref="fixedFileDescriptor" />
</bean>
<bean id="fileInputTemplate2" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource"
scope="step">
<aop:scoped-proxy />
<property name="resource" ref="fileLocator2" />
<property name="tokenizer" ref="fixedFileDescriptor2" />
<!-- <property name="validator" ref="fixedValidator" />-->
</bean>
<bean id="fixedFileDescriptor"
class="org.springframework.batch.io.file.support.transform.FixedLengthTokenizer">
<property name="names" value="ISIN,Quantity,price, CUSTOMER" />
<property name="lengths" value="12, 3, 5, 9" />
</bean>
<bean id="fixedFileDescriptor2"
class="org.springframework.batch.io.file.support.transform.FixedLengthTokenizer">
<property name="names" value="Title, FirstName, LastName, Age, Address.AddrLine1, children[0].name, children[1].name" />
<property name="lengths" value="5, 15, 20, 5, 10, 10, 10" />
</bean>
<bean id="fixedValidator" class="org.springframework.batch.item.validator.SpringValidator">
<property name="validator">
<bean id="tradeValidator" class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value>
<![CDATA[
{ isin : length(?) < 13 : 'ISIN too long' : 'isin_length' : 12}
]]>
</value>
</property>
</bean>
</property>
</bean>
<bean id="tradeDao" class="org.springframework.batch.sample.dao.JdbcTradeWriter">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="incrementer">
<bean parent="incrementerParent">
<property name="incrementerName" value="TRADE_SEQ" />
</bean>
</property>
</bean>
<bean id="fileLocator" class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String"
value="data/beanWrapperMapperSampleJob/input/20070122.teststream.ImportTradeDataStep.txt" />
</bean>
<bean id="fileLocator2" class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String"
value="data/beanWrapperMapperSampleJob/input/20070122.teststream.ImportPersonDataStep.txt" />
</bean>
<bean id="fieldSetMapper" class="org.springframework.batch.io.file.support.mapping.BeanWrapperFieldSetMapper">
<property name="prototypeBeanName" value="trade"/>
</bean>
<bean id="fieldSetMapper2" class="org.springframework.batch.io.file.support.mapping.BeanWrapperFieldSetMapper">
<property name="prototypeBeanName" value="person"/>
</bean>
<bean id="trade" class="org.springframework.batch.sample.domain.Trade" scope="prototype"/>
<bean id="person" class="org.springframework.batch.sample.domain.Person" scope="prototype"/>
</beans>

View File

@@ -49,7 +49,9 @@
<!-- INFRASTRUCTURE SETUP -->
<bean id="fileInputTemplate" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource">
<bean id="fileInputTemplate" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource"
scope="step">
<aop:scoped-proxy />
<property name="resource" ref="fileLocator" />
<property name="tokenizer" ref="fixedFileDescriptor" />
</bean>

View File

@@ -1,85 +1,95 @@
<?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-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry"/>
</bean>
<bean id="jobConfiguration" parent="simpleJob">
<property name="name" value="fixedLengthImportJob" />
<property name="steps">
<bean id="step1" parent="simpleStep">
<constructor-arg>
<bean
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean
class="org.springframework.batch.item.provider.FlatFileItemProvider">
<property name="source" ref="fileInputTemplate" />
<property name="mapper" ref="fieldSetMapper" />
<property name="validator" ref="fixedValidator" />
</bean>
</property>
<property name="itemProcessor">
<bean class="org.springframework.batch.sample.module.process.TradeProcessor">
<property name="writer" ref="tradeDao" />
</bean>
</property>
</bean>
</constructor-arg>
</bean>
</property>
</bean>
<!-- INFRASTRUCTURE SETUP -->
<bean id="fileInputTemplate" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource">
<property name="resource" ref="fileLocator" />
<property name="tokenizer" ref="fixedFileDescriptor" />
</bean>
<bean id="fixedFileDescriptor" class="org.springframework.batch.io.file.support.transform.FixedLengthTokenizer">
<property name="names" value="ISIN, Quantity, Price, Customer" />
<property name="lengths" value="12, 3, 5, 9" />
</bean>
<bean id="fixedValidator" class="org.springframework.batch.item.validator.SpringValidator">
<property name="validator">
<bean id="tradeValidator" class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value>
<![CDATA[
{ isin : length(?) < 13 : 'ISIN too long' : 'isin_length' : 12}
]]>
</value>
</property>
</bean>
</property>
</bean>
<bean id="tradeDao" class="org.springframework.batch.sample.dao.JdbcTradeWriter">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="incrementer">
<bean parent="incrementerParent">
<property name="incrementerName" value="TRADE_SEQ" />
</bean>
</property>
</bean>
<bean id="fileLocator" class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String"
value="data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt" />
</bean>
<bean id="fieldSetMapper" class="org.springframework.batch.sample.mapping.TradeFieldSetMapper" />
<?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-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry"/>
</bean>
<bean id="jobConfiguration" parent="simpleJob">
<property name="name" value="fixedLengthImportJob" />
<property name="steps">
<bean id="step1" parent="simpleStep">
<constructor-arg>
<bean
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean
class="org.springframework.batch.item.provider.FlatFileItemProvider">
<property name="source" ref="fileInputTemplate" />
<property name="mapper" ref="fieldSetMapper" />
<property name="validator" ref="fixedValidator" />
</bean>
</property>
<property name="itemProcessor">
<bean class="org.springframework.batch.sample.module.process.TradeProcessor">
<property name="writer" ref="tradeDao" />
</bean>
</property>
</bean>
</constructor-arg>
</bean>
</property>
</bean>
<!-- INFRASTRUCTURE SETUP -->
<bean id="abstractInputTemplate" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource"
abstract="true">
<property name="resource" ref="fileLocator" />
<property name="tokenizer" ref="fixedFileDescriptor" />
</bean>
<!-- TODO: refactor this to use aop:scoped-proxy when SPR-3804 is fixed -->
<bean id="scopedInputTemplate" parent="abstractInputTemplate" autowire-candidate="false" scope="step"/>
<bean id="fileInputTemplate" class="org.springframework.aop.scope.ScopedProxyFactoryBean" autowire-candidate="false">
<property name="proxyTargetClass" value="true"/>
<property name="targetBeanName" value="scopedInputTemplate"/>
</bean>
<bean id="testInputTemplate" parent="abstractInputTemplate"/>
<bean id="fixedFileDescriptor" class="org.springframework.batch.io.file.support.transform.FixedLengthTokenizer">
<property name="names" value="ISIN, Quantity, Price, Customer" />
<property name="lengths" value="12, 3, 5, 9" />
</bean>
<bean id="fixedValidator" class="org.springframework.batch.item.validator.SpringValidator">
<property name="validator">
<bean id="tradeValidator" class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value>
<![CDATA[
{ isin : length(?) < 13 : 'ISIN too long' : 'isin_length' : 12}
]]>
</value>
</property>
</bean>
</property>
</bean>
<bean id="tradeDao" class="org.springframework.batch.sample.dao.JdbcTradeWriter">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="incrementer">
<bean parent="incrementerParent">
<property name="incrementerName" value="TRADE_SEQ" />
</bean>
</property>
</bean>
<bean id="fileLocator" class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String"
value="data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt" />
</bean>
<bean id="fieldSetMapper" class="org.springframework.batch.sample.mapping.TradeFieldSetMapper" />
</beans>

View File

@@ -1,76 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry"/>
</bean>
<bean id="jobConfiguration" parent="simpleJob">
<property name="name" value="multilineJob" />
<property name="steps">
<bean id="step1" parent="simpleStep">
<constructor-arg>
<bean
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean class="org.springframework.batch.sample.module.CollectionItemProvider">
<property name="inputSource" ref="fileInputTemplate" />
<property name="fieldSetMapper" ref="tradeLineMapper" />
</bean>
</property>
<property name="itemProcessor">
<bean class="org.springframework.batch.sample.module.process.DefaultFlatFileProcessor">
<property name="flatFileOutputSource">
<bean class="org.springframework.batch.io.file.support.FlatFileOutputSource" >
<property name="resource" value="file:20070122.testStream.multilineStep.txt" />
</bean>
</property>
</bean>
</property>
</bean>
</constructor-arg>
</bean>
</property>
</bean>
<bean id="fileInputTemplate" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource">
<property name="resource" value="classpath:data/multilineJob/input/20070122.teststream.multilineStep.txt" />
<property name="tokenizer" ref="fixedFileDescriptor" />
<!-- <property name="validator" ref="fixedValidator" /> -->
</bean>
<bean id="tradeLineMapper" class="org.springframework.batch.sample.mapping.TradeFieldSetMapper" />
<bean id="fixedFileDescriptor"
class="org.springframework.batch.io.file.support.transform.PrefixMatchingCompositeLineTokenizer">
<property name="tokenizers">
<map>
<entry key="BEGIN" value-ref="beginRecordDescriptor" />
<entry key="END" value-ref="endRecordDescriptor" />
<entry key="" value-ref="tradeRecordDescriptor" />
</map>
</property>
</bean>
<bean id="beginRecordDescriptor"
class="org.springframework.batch.io.file.support.transform.FixedLengthTokenizer">
<property name="lengths" value="5" />
</bean>
<bean id="endRecordDescriptor"
class="org.springframework.batch.io.file.support.transform.FixedLengthTokenizer">
<property name="lengths" value="3" />
</bean>
<bean id="tradeRecordDescriptor"
class="org.springframework.batch.io.file.support.transform.FixedLengthTokenizer">
<property name="names" value="ISIN,Quantity,Price,Customer" />
<property name="lengths" value="12,3,5,9" />
</bean>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry"/>
</bean>
<bean id="jobConfiguration" parent="simpleJob">
<property name="name" value="multilineJob" />
<property name="steps">
<bean id="step1" parent="simpleStep">
<constructor-arg>
<bean
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean class="org.springframework.batch.sample.module.CollectionItemProvider">
<property name="inputSource" ref="fileInputTemplate" />
<property name="fieldSetMapper" ref="tradeLineMapper" />
</bean>
</property>
<property name="itemProcessor">
<bean class="org.springframework.batch.sample.module.process.DefaultFlatFileProcessor">
<property name="flatFileOutputSource">
<bean class="org.springframework.batch.io.file.support.FlatFileOutputSource"
scope="step" >
<aop:scoped-proxy />
<property name="resource" value="file:20070122.testStream.multilineStep.txt" />
</bean>
</property>
</bean>
</property>
</bean>
</constructor-arg>
</bean>
</property>
</bean>
<bean id="fileInputTemplate" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource"
scope="step">
<aop:scoped-proxy />
<property name="resource" value="classpath:data/multilineJob/input/20070122.teststream.multilineStep.txt" />
<property name="tokenizer" ref="fixedFileDescriptor" />
<!-- <property name="validator" ref="fixedValidator" /> -->
</bean>
<bean id="tradeLineMapper" class="org.springframework.batch.sample.mapping.TradeFieldSetMapper" />
<bean id="fixedFileDescriptor"
class="org.springframework.batch.io.file.support.transform.PrefixMatchingCompositeLineTokenizer">
<property name="tokenizers">
<map>
<entry key="BEGIN" value-ref="beginRecordDescriptor" />
<entry key="END" value-ref="endRecordDescriptor" />
<entry key="" value-ref="tradeRecordDescriptor" />
</map>
</property>
</bean>
<bean id="beginRecordDescriptor"
class="org.springframework.batch.io.file.support.transform.FixedLengthTokenizer">
<property name="lengths" value="5" />
</bean>
<bean id="endRecordDescriptor"
class="org.springframework.batch.io.file.support.transform.FixedLengthTokenizer">
<property name="lengths" value="3" />
</bean>
<bean id="tradeRecordDescriptor"
class="org.springframework.batch.io.file.support.transform.FixedLengthTokenizer">
<property name="names" value="ISIN,Quantity,Price,Customer" />
<property name="lengths" value="12,3,5,9" />
</bean>
</beans>

View File

@@ -1,21 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="fileInputTemplate" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource">
<property name="resource" ref="fileInputLocator" />
<property name="tokenizer" ref="orderFileDescriptor" />
</bean>
<bean id="flatFileOutputSource" class="org.springframework.batch.io.file.support.FlatFileOutputSource">
<property name="resource" ref="fileOutputLocator" />
</bean>
<bean id="delimitedLineAggregator" class="org.springframework.batch.io.file.support.transform.DelimitedLineTokenizer" />
<bean id="fixedLineAggregator" class="org.springframework.batch.io.file.support.transform.FixedLengthLineAggregator" />
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="fileInputTemplate" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource"
scope="step">
<aop:scoped-proxy />
<property name="resource" ref="fileInputLocator" />
<property name="tokenizer" ref="orderFileDescriptor" />
</bean>
<bean id="flatFileOutputSource" class="org.springframework.batch.io.file.support.FlatFileOutputSource"
scope="step" >
<aop:scoped-proxy />
<property name="resource" ref="fileOutputLocator" />
</bean>
<bean id="delimitedLineAggregator" class="org.springframework.batch.io.file.support.transform.DelimitedLineTokenizer" />
<bean id="fixedLineAggregator" class="org.springframework.batch.io.file.support.transform.FixedLengthLineAggregator" />
</beans>

View File

@@ -1,85 +1,85 @@
<?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-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry"/>
</bean>
<bean id="jobConfiguration" parent="simpleJob" p:name="restartSample">
<property name="steps">
<bean id="step1" parent="simpleStep">
<constructor-arg>
<bean class="org.springframework.batch.sample.module.ExceptionRestartableTasklet">
<property name="itemProvider">
<bean
class="org.springframework.batch.item.provider.FlatFileItemProvider">
<property name="source" ref="fileInputTemplate" />
<property name="mapper" ref="fieldSetMapper" />
<property name="validator" ref="fixedValidator" />
</bean>
</property>
<property name="itemProcessor">
<bean class="org.springframework.batch.sample.module.process.TradeProcessor">
<property name="writer" ref="tradeDao" />
</bean>
</property>
</bean>
</constructor-arg>
<property name="commitInterval" value="2" />
</bean>
</property>
</bean>
<!-- INFRASTRUCTURE SETUP -->
<bean id="fileInputTemplate" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource">
<property name="resource" ref="fileLocator" />
<property name="tokenizer" ref="fixedFileDescriptor" />
</bean>
<bean id="fixedFileDescriptor" class="org.springframework.batch.io.file.support.transform.FixedLengthTokenizer">
<property name="names" value="ISIN, Quantity, Price, Customer" />
<property name="lengths" value="12, 3, 5, 9" />
</bean>
<bean id="fixedValidator" class="org.springframework.batch.item.validator.SpringValidator">
<property name="validator">
<bean id="tradeValidator" class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value>
<![CDATA[
{ isin : length(?) < 13 : 'ISIN too long' : 'isin_length' : 12}
]]>
</value>
</property>
</bean>
</property>
</bean>
<bean id="tradeDao" class="org.springframework.batch.sample.dao.JdbcTradeWriter">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="incrementer">
<bean parent="incrementerParent">
<property name="incrementerName" value="TRADE_SEQ" />
</bean>
</property>
</bean>
<bean id="fileLocator" class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String"
value="data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt" />
</bean>
<bean id="fieldSetMapper" class="org.springframework.batch.sample.mapping.TradeFieldSetMapper" />
<?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-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry"/>
</bean>
<bean id="jobConfiguration" parent="simpleJob" p:name="restartSample">
<property name="steps">
<bean id="step1" parent="simpleStep">
<property name="tasklet">
<bean class="org.springframework.batch.sample.module.ExceptionRestartableTasklet">
<property name="itemProvider">
<bean
class="org.springframework.batch.item.provider.FlatFileItemProvider">
<property name="source" ref="fileInputTemplate" />
<property name="mapper" ref="fieldSetMapper" />
<property name="validator" ref="fixedValidator" />
</bean>
</property>
<property name="itemProcessor">
<bean class="org.springframework.batch.sample.module.process.TradeProcessor">
<property name="writer" ref="tradeDao" />
</bean>
</property>
</bean>
</property>
<property name="commitInterval" value="2" />
</bean>
</property>
</bean>
<!-- INFRASTRUCTURE SETUP -->
<bean id="fileInputTemplate" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource">
<property name="resource" ref="fileLocator" />
<property name="tokenizer" ref="fixedFileDescriptor" />
</bean>
<bean id="fixedFileDescriptor" class="org.springframework.batch.io.file.support.transform.FixedLengthTokenizer">
<property name="names" value="ISIN, Quantity, Price, Customer" />
<property name="lengths" value="12, 3, 5, 9" />
</bean>
<bean id="fixedValidator" class="org.springframework.batch.item.validator.SpringValidator">
<property name="validator">
<bean id="tradeValidator" class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value>
<![CDATA[
{ isin : length(?) < 13 : 'ISIN too long' : 'isin_length' : 12}
]]>
</value>
</property>
</bean>
</property>
</bean>
<bean id="tradeDao" class="org.springframework.batch.sample.dao.JdbcTradeWriter">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="incrementer">
<bean parent="incrementerParent">
<property name="incrementerName" value="TRADE_SEQ" />
</bean>
</property>
</bean>
<bean id="fileLocator" class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String"
value="data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt" />
</bean>
<bean id="fieldSetMapper" class="org.springframework.batch.sample.mapping.TradeFieldSetMapper" />
</beans>

View File

@@ -1,69 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry"/>
</bean>
<bean id="jobConfiguration" parent="simpleJob">
<property name="name" value="simpleTaskletJob" />
<property name="steps">
<list>
<bean id="step1" parent="simpleStep">
<constructor-arg>
<bean id="tradeTasklet" class="org.springframework.batch.sample.module.SimpleTradeTasklet">
<property name="inputSource" ref="fileInputSource" />
<property name="tradeDao" ref="tradeDao" />
</bean>
</constructor-arg>
<property name="commitInterval" value="2" />
</bean>
</list>
</property>
</bean>
<bean id="tradeDao" class="org.springframework.batch.sample.dao.JdbcTradeWriter">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="incrementer">
<bean parent="incrementerParent">
<property name="incrementerName" value="TRADE_SEQ" />
</bean>
</property>
</bean>
<bean id="fileInputSource" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource">
<property name="resource" ref="fileLocator" />
<property name="tokenizer" ref="fixedFileDescriptor" />
</bean>
<bean id="fixedFileDescriptor" class="org.springframework.batch.io.file.support.transform.FixedLengthTokenizer">
<property name="names" value="ISIN, Quantity, Price, Customer" />
<property name="lengths" value="12, 3, 5, 9" />
</bean>
<bean id="fileLocator" class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String"
value="data/simpleTaskletJob/input/20070122.teststream.ImportTradeDataStep.txt" />
</bean>
<bean id="tradeLogAdvice"
class="org.springframework.batch.sample.advice.TradeWriterLogAdvice" />
<aop:config>
<aop:aspect id="tradeWriterLogging" ref="tradeLogAdvice">
<aop:after
pointcut="execution( * org.springframework.batch.sample.dao.TradeWriter+.writeTrade(org.springframework.batch.sample.domain.Trade)) and args(trade)"
method="doBasicLogging" />
</aop:aspect>
</aop:config>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry"/>
</bean>
<bean id="jobConfiguration" parent="simpleJob">
<property name="name" value="simpleTaskletJob" />
<property name="steps">
<list>
<bean id="step1" parent="simpleStep">
<constructor-arg>
<bean id="tradeTasklet" class="org.springframework.batch.sample.module.SimpleTradeTasklet">
<property name="inputSource" ref="fileInputSource" />
<property name="tradeDao" ref="tradeDao" />
</bean>
</constructor-arg>
<property name="commitInterval" value="2" />
</bean>
</list>
</property>
</bean>
<bean id="tradeDao" class="org.springframework.batch.sample.dao.JdbcTradeWriter">
<property name="jdbcTemplate" ref="jdbcTemplate" />
<property name="incrementer">
<bean parent="incrementerParent">
<property name="incrementerName" value="TRADE_SEQ" />
</bean>
</property>
</bean>
<bean id="abstractInputTemplate" class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource"
abstract="true">
<property name="resource" ref="fileLocator" />
<property name="tokenizer" ref="fixedFileDescriptor" />
</bean>
<!-- TODO: refactor this to use aop:scoped-proxy when SPR-3804 is fixed -->
<bean id="scopedInputTemplate" parent="abstractInputTemplate" autowire-candidate="false" scope="step"/>
<bean id="fileInputSource" class="org.springframework.aop.scope.ScopedProxyFactoryBean" autowire-candidate="false">
<property name="proxyTargetClass" value="true"/>
<property name="targetBeanName" value="scopedInputTemplate"/>
</bean>
<bean id="testInputTemplate" parent="abstractInputTemplate"/>
<bean id="fixedFileDescriptor" class="org.springframework.batch.io.file.support.transform.FixedLengthTokenizer">
<property name="names" value="ISIN, Quantity, Price, Customer" />
<property name="lengths" value="12, 3, 5, 9" />
</bean>
<bean id="fileLocator" class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String"
value="data/simpleTaskletJob/input/20070122.teststream.ImportTradeDataStep.txt" />
</bean>
<bean id="tradeLogAdvice"
class="org.springframework.batch.sample.advice.TradeWriterLogAdvice" />
<aop:config>
<aop:aspect id="tradeWriterLogging" ref="tradeLogAdvice">
<aop:after
pointcut="execution( * org.springframework.batch.sample.dao.TradeWriter+.writeTrade(org.springframework.batch.sample.domain.Trade)) and args(trade)"
method="doBasicLogging" />
</aop:aspect>
</aop:config>
</beans>

View File

@@ -1,108 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<import resource="tradeJobIo.xml" />
<!--import resource="tradeJobAop.xml" /-->
<bean class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry" />
</bean>
<bean id="jobConfiguration" parent="simpleJob">
<property name="name" value="tradeJob" />
<property name="steps">
<list>
<bean id="step1" parent="simpleStep">
<constructor-arg>
<bean class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean
class="org.springframework.batch.item.provider.FlatFileItemProvider">
<property name="source" ref="fileInputTemplate" />
<property name="mapper">
<bean class="org.springframework.batch.sample.mapping.TradeFieldSetMapper" />
</property>
<property name="validator" ref="tradeValidator" />
</bean>
</property>
<property name="itemProcessor">
<bean class="org.springframework.batch.sample.module.process.TradeProcessor"
p:writer-ref="tradeDao" />
</property>
</bean>
</constructor-arg>
</bean>
<bean id="step2" parent="simpleStep">
<constructor-arg>
<bean class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean
class="org.springframework.batch.item.provider.InputSourceItemProvider">
<property name="inputSource">
<bean class="org.springframework.batch.io.sql.SqlCursorInputSource">
<constructor-arg>
<ref bean="dataSource" />
</constructor-arg>
<property name="sql"
value="SELECT id, quantity, price, customer from TRADE" />
<property name="mapper">
<bean class="org.springframework.batch.sample.mapping.TradeRowMapper" />
</property>
</bean>
</property>
</bean>
</property>
<property name="itemProcessor">
<bean class="org.springframework.batch.sample.module.process.CustomerUpdateProcessor"
p:dao-ref="customerDao" />
</property>
</bean>
</constructor-arg>
</bean>
<bean id="step3" parent="simpleStep">
<constructor-arg>
<bean class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean
class="org.springframework.batch.item.provider.InputSourceItemProvider">
<property name="inputSource">
<bean class="org.springframework.batch.io.sql.SqlCursorInputSource">
<constructor-arg>
<ref bean="dataSource" />
</constructor-arg>
<property name="sql" value="SELECT id, name, credit FROM customer " />
<property name="mapper">
<bean
class="org.springframework.batch.sample.mapping.CustomerCreditRowMapper" />
</property>
</bean>
</property>
</bean>
</property>
<property name="itemProcessor">
<bean
class="org.springframework.batch.sample.module.process.CustomerCreditUpdateProcessor"
p:writer-ref="customerReportOutputSource" />
</property>
</bean>
</constructor-arg>
</bean>
</list>
</property>
</bean>
<bean id="fileLocator" class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String"
value="data/tradeJob/input/20070122.teststream.ImportTradeDataStep.txt" />
</bean>
<bean id="customerFileLocator" class="org.springframework.core.io.FileSystemResource">
<constructor-arg type="java.lang.String" value="20070122.testStream.CustomerReportStep.TEMP.txt" />
</bean>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<import resource="tradeJobIo.xml" />
<!--import resource="tradeJobAop.xml" /-->
<bean
class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
<property name="jobConfigurationRegistry"
ref="jobConfigurationRegistry" />
</bean>
<bean id="jobConfiguration" parent="simpleJob">
<property name="name" value="tradeJob" />
<property name="steps">
<list>
<bean id="step1" parent="simpleStep">
<property name="tasklet">
<bean
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean
class="org.springframework.batch.item.provider.FlatFileItemProvider">
<property name="source"
ref="fileInputTemplate" />
<property name="mapper">
<bean
class="org.springframework.batch.sample.mapping.TradeFieldSetMapper" />
</property>
<property name="validator"
ref="tradeValidator" />
</bean>
</property>
<property name="itemProcessor">
<bean
class="org.springframework.batch.sample.module.process.TradeProcessor"
p:writer-ref="tradeDao" />
</property>
</bean>
</property>
</bean>
<bean id="step2" parent="simpleStep">
<property name="tasklet">
<bean
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean
class="org.springframework.batch.item.provider.InputSourceItemProvider">
<property name="inputSource"
ref="tradeSqlInputSOurce" />
</bean>
</property>
<property name="itemProcessor">
<bean
class="org.springframework.batch.sample.module.process.CustomerUpdateProcessor"
p:dao-ref="customerDao" />
</property>
</bean>
</property>
</bean>
<bean id="step3" parent="simpleStep">
<property name="tasklet">
<bean
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean
class="org.springframework.batch.item.provider.InputSourceItemProvider">
<property name="inputSource" ref="customerSqlInputSource" />
</bean>
</property>
<property name="itemProcessor">
<bean
class="org.springframework.batch.sample.module.process.CustomerCreditUpdateProcessor"
p:writer-ref="customerReportOutputSource" />
</property>
</bean>
</property>
</bean>
</list>
</property>
</bean>
<bean id="tradeSqlInputSOurce"
class="org.springframework.batch.io.sql.SqlCursorInputSource"
scope="step">
<aop:scoped-proxy />
<property name="dataSource" ref="dataSource" />
<property name="sql"
value="SELECT id, quantity, price, customer from TRADE" />
<property name="mapper">
<bean
class="org.springframework.batch.sample.mapping.TradeRowMapper" />
</property>
</bean>
<bean id="customerSqlInputSource" class="org.springframework.batch.io.sql.SqlCursorInputSource"
scope="step">
<aop:scoped-proxy />
<property name="dataSource" ref="dataSource" />
<property name="sql"
value="SELECT id, name, credit FROM customer " />
<property name="mapper">
<bean
class="org.springframework.batch.sample.mapping.CustomerCreditRowMapper" />
</property>
</bean>
<bean id="fileLocator"
class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String"
value="data/tradeJob/input/20070122.teststream.ImportTradeDataStep.txt" />
</bean>
<bean id="customerFileLocator"
class="org.springframework.core.io.FileSystemResource">
<constructor-arg type="java.lang.String"
value="20070122.testStream.CustomerReportStep.TEMP.txt" />
</bean>
</beans>

View File

@@ -1,52 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean class="org.springframework.batch.sample.dao.JdbcTradeWriter" id="tradeDao"
p:jdbcTemplate-ref="jdbcTemplate">
<property name="incrementer">
<bean parent="incrementerParent">
<property name="incrementerName" value="TRADE_SEQ" />
</bean>
</property>
</bean>
<bean class="org.springframework.batch.sample.dao.JdbcCustomerDebitWriter" id="customerDao" p:jdbcTemplate-ref="jdbcTemplate" />
<bean class="org.springframework.batch.sample.dao.FlatFileCustomerCreditWriter" id="customerReportOutputSource"
p:outputSource-ref="customerFlatFileOutputSource" />
<bean class="org.springframework.batch.io.file.support.FlatFileOutputSource" id="customerFlatFileOutputSource">
<property name="resource" ref="customerFileLocator" />
</bean>
<bean class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource" id="fileInputTemplate">
<property name="resource" ref="fileLocator" />
<property name="tokenizer" ref="tradeFileDescriptor" />
</bean>
<bean id="tradeFileDescriptor"
class="org.springframework.batch.io.file.support.transform.DelimitedLineTokenizer">
<property name="names" value="ISIN, Quantity, Price, Customer" />
</bean>
<bean id="tradeValidator" class="org.springframework.batch.item.validator.SpringValidator">
<property name="validator">
<bean class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value>
<![CDATA[
{ isin : length(?) < 13 : 'ISIN too long' : 'isin_length' : 12}
]]>
</value>
</property>
</bean>
</property>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean class="org.springframework.batch.sample.dao.JdbcTradeWriter" id="tradeDao"
p:jdbcTemplate-ref="jdbcTemplate">
<property name="incrementer">
<bean parent="incrementerParent">
<property name="incrementerName" value="TRADE_SEQ" />
</bean>
</property>
</bean>
<bean class="org.springframework.batch.sample.dao.JdbcCustomerDebitWriter" id="customerDao" p:jdbcTemplate-ref="jdbcTemplate" />
<bean class="org.springframework.batch.sample.dao.FlatFileCustomerCreditWriter" id="customerReportOutputSource"
p:outputSource-ref="customerFlatFileOutputSource" />
<bean class="org.springframework.batch.io.file.support.FlatFileOutputSource" id="customerFlatFileOutputSource"
scope="step" >
<aop:scoped-proxy />
<property name="resource" ref="customerFileLocator" />
</bean>
<bean class="org.springframework.batch.io.file.support.DefaultFlatFileInputSource" id="fileInputTemplate"
scope="step">
<aop:scoped-proxy />
<property name="resource" ref="fileLocator" />
<property name="tokenizer" ref="tradeFileDescriptor" />
</bean>
<bean id="tradeFileDescriptor"
class="org.springframework.batch.io.file.support.transform.DelimitedLineTokenizer">
<property name="names" value="ISIN, Quantity, Price, Customer" />
</bean>
<bean id="tradeValidator" class="org.springframework.batch.item.validator.SpringValidator">
<property name="validator">
<bean class="org.springmodules.validation.valang.ValangValidator">
<property name="valang">
<value>
<![CDATA[
{ isin : length(?) < 13 : 'ISIN too long' : 'isin_length' : 12}
]]>
</value>
</property>
</bean>
</property>
</bean>
</beans>

View File

@@ -1,118 +1,119 @@
<?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-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry"/>
</bean>
<bean id="jobConfiguration" parent="simpleJob">
<property name="name" value="xmlJob" />
<property name="steps">
<bean id="step1" parent="simpleStep">
<constructor-arg>
<bean
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean
class="org.springframework.batch.item.provider.InputSourceItemProvider">
<property name="inputSource">
<bean class="org.springframework.batch.io.xml.XmlInputSource">
<property name="name" value="XmlFileInputSource" />
<property name="resource"
value="data/xmlJob/input/20070122.testStream.xmlFileStep.xml" />
<property name="validating" value="true" />
<property name="inputFactory">
<bean class="org.springframework.batch.io.xml.xstream.XStreamFactory">
<property name="config" ref="streamConfig2" />
</bean>
</property>
</bean>
</property>
</bean>
</property>
<property name="itemProcessor">
<bean class="org.springframework.batch.item.processor.OutputSourceItemProcessor">
<property name="outputSource">
<bean class="org.springframework.batch.io.xml.XmlOutputSource" scope="step">
<aop:scoped-proxy/>
<property name="name" value="XmlFileOutputSource" />
<property name="resource" value="file:20070122.testStream.xmlFileStep.xml" />
<property name="outputFactory">
<bean class="org.springframework.batch.io.xml.xstream.XStreamFactory">
<property name="config" ref="streamConfig" />
</bean>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</constructor-arg>
</bean>
</property>
</bean>
<bean id="streamConfig" class="org.springframework.batch.io.xml.xstream.XStreamConfigurationFactoryBean">
<property name="configFile" value="xstream-config.xml" />
</bean>
<bean id="streamConfig2" class="org.springframework.batch.io.xml.xstream.XStreamConfiguration">
<property name="rootElementName" value="purchaseOrders" />
<property name="rootElementAttributes">
<map>
<entry key="xmlns" value="http://adsj.accenture.com/purchaseorders" />
<entry key="xmlns:xsi" value="http://www.w3.org/2001/XMLSchema-instance" />
<entry key="xsi:schemaLocation" value="http://adsj.accenture.com/purchaseorders purchaseorders.xsd" />
</map>
</property>
<property name="fieldAliases">
<list>
<bean class="org.springframework.batch.io.xml.xstream.FieldAlias">
<property name="aliasName" value="org.springframework.batch.sample.domain.xml.Customer" />
<property name="type" value="org.springframework.batch.sample.domain.xml.Order" />
<property name="fieldName" value="customer" />
</bean>
<bean class="org.springframework.batch.io.xml.xstream.FieldAlias">
<property name="aliasName" value="org.springframework.batch.sample.domain.xml.Shipper" />
<property name="type" value="org.springframework.batch.sample.domain.xml.Order" />
<property name="fieldName" value="shiper" />
</bean>
</list>
</property>
<property name="mappings">
<list>
<bean class="org.springframework.batch.io.xml.xstream.Mapping">
<property name="namespaceURI" value="http://adsj.accenture.com/purchaseorders" />
<property name="localPart" value="order" />
<property name="prefix" value="" />
<property name="className" value="org.springframework.batch.sample.domain.xml.Order" />
</bean>
<bean class="org.springframework.batch.io.xml.xstream.Mapping">
<property name="namespaceURI" value="http://adsj.accenture.com/purchaseorders" />
<property name="localPart" value="customer" />
<property name="prefix" value="" />
<property name="className" value="org.springframework.batch.sample.domain.xml.Customer" />
</bean>
<bean class="org.springframework.batch.io.xml.xstream.Mapping">
<property name="namespaceURI" value="http://adsj.accenture.com/purchaseorders" />
<property name="localPart" value="shipper" />
<property name="prefix" value="" />
<property name="className" value="org.springframework.batch.sample.domain.xml.Shipper" />
</bean>
<bean class="org.springframework.batch.io.xml.xstream.Mapping">
<property name="namespaceURI" value="http://adsj.accenture.com/purchaseorders" />
<property name="localPart" value="lineItem" />
<property name="prefix" value="" />
<property name="className" value="org.springframework.batch.sample.domain.xml.LineItem" />
</bean>
</list>
</property>
</bean>
<?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-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean class="org.springframework.batch.execution.configuration.JobConfigurationRegistryBeanPostProcessor">
<property name="jobConfigurationRegistry" ref="jobConfigurationRegistry"/>
</bean>
<bean id="jobConfiguration" parent="simpleJob">
<property name="name" value="xmlJob" />
<property name="steps">
<bean id="step1" parent="simpleStep">
<constructor-arg>
<bean
class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean
class="org.springframework.batch.item.provider.InputSourceItemProvider">
<property name="inputSource">
<bean class="org.springframework.batch.io.xml.XmlInputSource" scope="step">
<aop:scoped-proxy/>
<property name="name" value="XmlFileInputSource" />
<property name="resource"
value="data/xmlJob/input/20070122.testStream.xmlFileStep.xml" />
<property name="validating" value="true" />
<property name="inputFactory">
<bean class="org.springframework.batch.io.xml.xstream.XStreamFactory">
<property name="config" ref="streamConfig2" />
</bean>
</property>
</bean>
</property>
</bean>
</property>
<property name="itemProcessor">
<bean class="org.springframework.batch.item.processor.OutputSourceItemProcessor">
<property name="outputSource">
<bean class="org.springframework.batch.io.xml.XmlOutputSource" scope="step">
<aop:scoped-proxy/>
<property name="name" value="XmlFileOutputSource" />
<property name="resource" value="file:20070122.testStream.xmlFileStep.xml" />
<property name="outputFactory">
<bean class="org.springframework.batch.io.xml.xstream.XStreamFactory">
<property name="config" ref="streamConfig" />
</bean>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</constructor-arg>
</bean>
</property>
</bean>
<bean id="streamConfig" class="org.springframework.batch.io.xml.xstream.XStreamConfigurationFactoryBean">
<property name="configFile" value="xstream-config.xml" />
</bean>
<bean id="streamConfig2" class="org.springframework.batch.io.xml.xstream.XStreamConfiguration">
<property name="rootElementName" value="purchaseOrders" />
<property name="rootElementAttributes">
<map>
<entry key="xmlns" value="http://adsj.accenture.com/purchaseorders" />
<entry key="xmlns:xsi" value="http://www.w3.org/2001/XMLSchema-instance" />
<entry key="xsi:schemaLocation" value="http://adsj.accenture.com/purchaseorders purchaseorders.xsd" />
</map>
</property>
<property name="fieldAliases">
<list>
<bean class="org.springframework.batch.io.xml.xstream.FieldAlias">
<property name="aliasName" value="org.springframework.batch.sample.domain.xml.Customer" />
<property name="type" value="org.springframework.batch.sample.domain.xml.Order" />
<property name="fieldName" value="customer" />
</bean>
<bean class="org.springframework.batch.io.xml.xstream.FieldAlias">
<property name="aliasName" value="org.springframework.batch.sample.domain.xml.Shipper" />
<property name="type" value="org.springframework.batch.sample.domain.xml.Order" />
<property name="fieldName" value="shiper" />
</bean>
</list>
</property>
<property name="mappings">
<list>
<bean class="org.springframework.batch.io.xml.xstream.Mapping">
<property name="namespaceURI" value="http://adsj.accenture.com/purchaseorders" />
<property name="localPart" value="order" />
<property name="prefix" value="" />
<property name="className" value="org.springframework.batch.sample.domain.xml.Order" />
</bean>
<bean class="org.springframework.batch.io.xml.xstream.Mapping">
<property name="namespaceURI" value="http://adsj.accenture.com/purchaseorders" />
<property name="localPart" value="customer" />
<property name="prefix" value="" />
<property name="className" value="org.springframework.batch.sample.domain.xml.Customer" />
</bean>
<bean class="org.springframework.batch.io.xml.xstream.Mapping">
<property name="namespaceURI" value="http://adsj.accenture.com/purchaseorders" />
<property name="localPart" value="shipper" />
<property name="prefix" value="" />
<property name="className" value="org.springframework.batch.sample.domain.xml.Shipper" />
</bean>
<bean class="org.springframework.batch.io.xml.xstream.Mapping">
<property name="namespaceURI" value="http://adsj.accenture.com/purchaseorders" />
<property name="localPart" value="lineItem" />
<property name="prefix" value="" />
<property name="className" value="org.springframework.batch.sample.domain.xml.LineItem" />
</bean>
</list>
</property>
</bean>
</beans>

View File

@@ -51,8 +51,6 @@ public class FixedLengthImportJobFunctionalTests extends AbstractLifecycleSpring
*/
protected void validatePostConditions() {
//ensure the input source is starts from the beginning
inputSource.close();
inputSource.open();
jdbcTemplate.query("SELECT ID, ISIN, QUANTITY, PRICE, CUSTOMER FROM trade ORDER BY id", new RowCallbackHandler() {