BATCH-982: committed patch

This commit is contained in:
lucasward
2008-12-31 05:27:13 +00:00
parent f6131a0f40
commit a9688adf76
15 changed files with 596 additions and 606 deletions

View File

@@ -1,33 +1,36 @@
<?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">
<!-- The tasklet used in this job will run in an infinite loop. This is useful for testing graceful shutdown from
multiple environments. -->
<bean id="loopJob" parent="simpleJob">
<property name="steps">
<bean id="step1" parent="simpleStep">
<property name="commitInterval" value="3" />
<property name="itemReader">
<bean class="org.springframework.batch.sample.common.InfiniteLoopReader" />
</property>
<property name="itemWriter">
<bean
class="org.springframework.batch.sample.common.InfiniteLoopWriter" />
</property>
</bean>
</property>
<property name="jobParametersIncrementer">
<bean class="org.springframework.batch.sample.common.InfiniteLoopIncrementer"/>
</property>
</bean>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:batch="http://www.springframework.org/schema/batch"
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/batch
http://www.springframework.org/schema/batch/spring-batch-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- The tasklet used in this job will run in an infinite loop. This is useful for testing graceful shutdown from
multiple environments. -->
<batch:job id="loopJob" incrementer="jobParametersIncrementer">
<batch:step name="step1"/>
</batch:job>
<bean id="step1" parent="simpleStep">
<property name="commitInterval" value="3" />
<property name="itemReader">
<bean class="org.springframework.batch.sample.common.InfiniteLoopReader" />
</property>
<property name="itemWriter">
<bean
class="org.springframework.batch.sample.common.InfiniteLoopWriter" />
</property>
</bean>
<bean id="jobParametersIncrementer"
class="org.springframework.batch.sample.common.InfiniteLoopIncrementer"/>
<aop:config>
<aop:aspect ref="eventAdvice">
<aop:before
@@ -42,4 +45,4 @@
</aop:aspect>
</aop:config>
</beans>
</beans>

View File

@@ -1,107 +1,107 @@
<?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 id="beanWrapperMapperJob" parent="simpleJob">
<property name="steps">
<list>
<bean id="step1" parent="simpleStep">
<property name="itemReader" ref="tradeFileItemReader" />
<property name="itemProcessor">
<bean class="org.springframework.batch.item.validator.ValidatingItemProcessor">
<constructor-arg ref="fixedValidator" />
</bean>
</property>
<property name="itemWriter">
<bean class="org.springframework.batch.sample.domain.trade.internal.TradeWriter">
<property name="dao" ref="tradeDao" />
</bean>
</property>
</bean>
<bean id="step2" parent="simpleStep">
<property name="itemReader" ref="personFileItemReader" />
<property name="itemWriter">
<bean class="org.springframework.batch.sample.domain.person.internal.PersonWriter" />
</property>
</bean>
</list>
</property>
</bean>
<!-- INFRASTRUCTURE SETUP -->
<bean id="tradeFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource"
value="classpath:data/beanWrapperMapperSampleJob/input/20070122.teststream.ImportTradeDataStep.txt" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer" ref="tradeTokenizer" />
<property name="fieldSetMapper" ref="tradeFieldSetMapper" />
</bean>
</property>
</bean>
<bean id="personFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource"
value="classpath:data/beanWrapperMapperSampleJob/input/20070122.teststream.ImportPersonDataStep.txt" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer" ref="personTokenizer" />
<property name="fieldSetMapper" ref="personFieldSetMapper" />
</bean>
</property>
</bean>
<bean id="tradeTokenizer" class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
<property name="names" value="ISIN,Quantity,price, CUSTOMER" />
<property name="columns" value="1-12, 13-15, 16-20, 21-29" />
</bean>
<bean id="personTokenizer" class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
<property name="names"
value="Title, FirstName, LastName, Age, Address.AddrLine1, children[0].name, children[1].name" />
<property name="columns" value="1-5, 6-20, 21-40, 41-45, 46-55, 56-65, 66-75" />
</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.domain.trade.internal.JdbcTradeDao">
<property name="dataSource" ref="dataSource" />
<property name="incrementer">
<bean parent="incrementerParent">
<property name="incrementerName" value="TRADE_SEQ" />
</bean>
</property>
</bean>
<bean id="tradeFieldSetMapper" class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
<property name="prototypeBeanName" value="trade" />
</bean>
<bean id="personFieldSetMapper" class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
<property name="prototypeBeanName" value="person" />
</bean>
<bean id="trade" class="org.springframework.batch.sample.domain.trade.Trade" scope="prototype" />
<bean id="person" class="org.springframework.batch.sample.domain.person.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" xmlns:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-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">
<batch:job id="beanWrapperMapperJob">
<batch:step name="step1" next="step2"/>
<batch:step name="step2"/>
</batch:job>
<bean id="step1" parent="simpleStep">
<property name="itemReader" ref="tradeFileItemReader" />
<property name="itemProcessor">
<bean class="org.springframework.batch.item.validator.ValidatingItemProcessor">
<constructor-arg ref="fixedValidator" />
</bean>
</property>
<property name="itemWriter">
<bean class="org.springframework.batch.sample.domain.trade.internal.TradeWriter">
<property name="dao" ref="tradeDao" />
</bean>
</property>
</bean>
<bean id="step2" parent="simpleStep">
<property name="itemReader" ref="personFileItemReader" />
<property name="itemWriter">
<bean class="org.springframework.batch.sample.domain.person.internal.PersonWriter" />
</property>
</bean>
<!-- INFRASTRUCTURE SETUP -->
<bean id="tradeFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource"
value="classpath:data/beanWrapperMapperSampleJob/input/20070122.teststream.ImportTradeDataStep.txt" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer" ref="tradeTokenizer" />
<property name="fieldSetMapper" ref="tradeFieldSetMapper" />
</bean>
</property>
</bean>
<bean id="personFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource"
value="classpath:data/beanWrapperMapperSampleJob/input/20070122.teststream.ImportPersonDataStep.txt" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer" ref="personTokenizer" />
<property name="fieldSetMapper" ref="personFieldSetMapper" />
</bean>
</property>
</bean>
<bean id="tradeTokenizer" class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
<property name="names" value="ISIN,Quantity,price, CUSTOMER" />
<property name="columns" value="1-12, 13-15, 16-20, 21-29" />
</bean>
<bean id="personTokenizer" class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
<property name="names"
value="Title, FirstName, LastName, Age, Address.AddrLine1, children[0].name, children[1].name" />
<property name="columns" value="1-5, 6-20, 21-40, 41-45, 46-55, 56-65, 66-75" />
</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.domain.trade.internal.JdbcTradeDao">
<property name="dataSource" ref="dataSource" />
<property name="incrementer">
<bean parent="incrementerParent">
<property name="incrementerName" value="TRADE_SEQ" />
</bean>
</property>
</bean>
<bean id="tradeFieldSetMapper" class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
<property name="prototypeBeanName" value="trade" />
</bean>
<bean id="personFieldSetMapper" class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
<property name="prototypeBeanName" value="person" />
</bean>
<bean id="trade" class="org.springframework.batch.sample.domain.trade.Trade" scope="prototype" />
<bean id="person" class="org.springframework.batch.sample.domain.person.Person" scope="prototype" />
</beans>

View File

@@ -2,8 +2,10 @@
<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"
xmlns:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-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">
@@ -14,26 +16,26 @@
(see the two FlatFileItemWriters used in this example).]]>
</description>
<bean id="compositeItemWriterJob" parent="simpleJob">
<property name="steps">
<bean id="step1" parent="simpleStep">
<property name="streams">
<list>
<ref bean="fileItemReader" />
<ref bean="fileItemWriter1" />
<ref bean="fileItemWriter2" />
</list>
</property>
<property name="itemReader" ref="fileItemReader" />
<property name="itemProcessor">
<bean
class="org.springframework.batch.item.validator.ValidatingItemProcessor">
<constructor-arg ref="fixedValidator" />
</bean>
</property>
<property name="itemWriter" ref="compositeWriter" />
<batch:job id="compositeItemWriterJob">
<batch:step name="step1"/>
</batch:job>
<bean id="step1" parent="simpleStep">
<property name="streams">
<list>
<ref bean="fileItemReader" />
<ref bean="fileItemWriter1" />
<ref bean="fileItemWriter2" />
</list>
</property>
<property name="itemReader" ref="fileItemReader" />
<property name="itemProcessor">
<bean
class="org.springframework.batch.item.validator.ValidatingItemProcessor">
<constructor-arg ref="fixedValidator" />
</bean>
</property>
<property name="itemWriter" ref="compositeWriter" />
</bean>
<!-- INFRASTRUCTURE SETUP -->

View File

@@ -1,27 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:lang="http://www.springframework.org/schema/lang"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd">
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.0.xsd">
<bean name="customerFilterJob" parent="simpleJob">
<property name="steps">
<list>
<bean name="uploadCustomer" parent="skipLimitStep">
<property name="itemReader" ref="customerFileUploadReader" />
<property name="itemProcessor" ref="customerUpdateProcessor" />
<property name="itemWriter" >
<bean class="org.springframework.batch.sample.domain.trade.CustomerUpdateWriter" >
<property name="customerDao" ref="customerDao" />
</bean>
</property>
<property name="listeners" ref="customerTokenizer" />
</bean>
</list>
</property>
</bean>
<batch:job id="customerFilterJob">
<batch:step name="uploadCustomer"/>
</batch:job>
<bean name="uploadCustomer" parent="skipLimitStep">
<property name="itemReader" ref="customerFileUploadReader" />
<property name="itemProcessor" ref="customerUpdateProcessor" />
<property name="itemWriter" >
<bean class="org.springframework.batch.sample.domain.trade.CustomerUpdateWriter" >
<property name="customerDao" ref="customerDao" />
</bean>
</property>
<property name="listeners" ref="customerTokenizer" />
</bean>
<bean name="customerFileUploadReader" class="org.springframework.batch.item.file.FlatFileItemReader" >
<property name="resource" ref="customerFileResource" />
<property name="lineMapper">

View File

@@ -1,46 +1,42 @@
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:batch="http://www.springframework.org/schema/batch"
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">
<description>
The intent is to to give an example of how existing bean
definitions (e.g. from custom application's domain layer) can be
integrated into a batch job.
</description>
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-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 id="delegateJob" parent="simpleJob">
<property name="steps">
<bean id="step1" parent="simpleStep">
<property name="itemReader">
<bean
class="org.springframework.batch.item.adapter.ItemReaderAdapter">
<property name="targetObject"
ref="delegateObject" />
<property name="targetMethod" value="getData" />
</bean>
</property>
<property name="itemWriter">
<bean
class="org.springframework.batch.item.adapter.PropertyExtractingDelegatingItemWriter">
<property name="targetObject"
ref="delegateObject" />
<property name="targetMethod"
value="processPerson" />
<property
name="fieldsUsedAsTargetMethodArguments">
<list>
<value>firstName</value>
<value>address.city</value>
</list>
</property>
</bean>
<description>
The intent is to to give an example of how existing bean
definitions (e.g. from custom application's domain layer) can be
integrated into a batch job.
</description>
<batch:job id="delegateJob">
<batch:step name="step1"/>
</batch:job>
<bean id="step1" parent="simpleStep">
<property name="itemReader">
<bean class="org.springframework.batch.item.adapter.ItemReaderAdapter">
<property name="targetObject" ref="delegateObject" />
<property name="targetMethod" value="getData" />
</bean>
</property>
<property name="itemWriter">
<bean class="org.springframework.batch.item.adapter.PropertyExtractingDelegatingItemWriter">
<property name="targetObject" ref="delegateObject" />
<property name="targetMethod" value="processPerson" />
<property name="fieldsUsedAsTargetMethodArguments">
<list>
<value>firstName</value>
<value>address.city</value>
</list>
</property>
</bean>
</property>

View File

@@ -1,111 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:batch="http://www.springframework.org/schema/batch"
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/batch http://www.springframework.org/schema/batch/spring-batch-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 id="footballJob" parent="simpleJob">
<property name="steps">
<list>
<bean id="playerload" parent="simpleStep">
<property name="commitInterval" value="${job.commit.interval}" />
<property name="startLimit" value="100" />
<property name="itemReader"
ref="playerFileItemReader" />
<property name="itemWriter">
<bean
class="org.springframework.batch.sample.domain.football.internal.PlayerItemWriter">
<property name="playerDao">
<bean
class="org.springframework.batch.sample.domain.football.internal.JdbcPlayerDao">
<property name="dataSource"
ref="dataSource" />
</bean>
</property>
</bean>
</property>
</bean>
<bean id="gameLoad" parent="simpleStep">
<property name="itemReader"
ref="gameFileItemReader" />
<property name="itemWriter">
<bean
class="org.springframework.batch.sample.domain.football.internal.JdbcGameDao">
<property name="dataSource"
ref="dataSource" />
</bean>
</property>
<property name="commitInterval" value="${job.commit.interval}" />
</bean>
<bean id="playerSummarization" parent="simpleStep">
<property name="commitInterval" value="${job.commit.interval}" />
<property name="itemReader"
ref="playerSummarizationSource" />
<property name="itemWriter">
<bean
class="org.springframework.batch.sample.domain.football.internal.JdbcPlayerSummaryDao">
<property name="dataSource"
ref="dataSource" />
</bean>
</property>
</bean>
</list>
<batch:job id="footballJob">
<batch:step name="playerload" next="gameLoad"/>
<batch:step name="gameLoad" next="playerSummarization"/>
<batch:step name="playerSummarization"/>
</batch:job>
<bean id="playerload" parent="simpleStep">
<property name="commitInterval" value="${job.commit.interval}" />
<property name="startLimit" value="100" />
<property name="itemReader" ref="playerFileItemReader" />
<property name="itemWriter">
<bean class="org.springframework.batch.sample.domain.football.internal.PlayerItemWriter">
<property name="playerDao">
<bean class="org.springframework.batch.sample.domain.football.internal.JdbcPlayerDao">
<property name="dataSource" ref="dataSource" />
</bean>
</property>
</bean>
</property>
</bean>
<bean id="playerFileItemReader"
class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource"
value="classpath:data/footballjob/input/${player.file.name}" />
<bean id="gameLoad" parent="simpleStep">
<property name="itemReader" ref="gameFileItemReader" />
<property name="itemWriter">
<bean class="org.springframework.batch.sample.domain.football.internal.JdbcGameDao">
<property name="dataSource" ref="dataSource" />
</bean>
</property>
<property name="commitInterval" value="${job.commit.interval}" />
</bean>
<bean id="playerSummarization" parent="simpleStep">
<property name="commitInterval" value="${job.commit.interval}" />
<property name="itemReader" ref="playerSummarizationSource" />
<property name="itemWriter">
<bean class="org.springframework.batch.sample.domain.football.internal.JdbcPlayerSummaryDao">
<property name="dataSource" ref="dataSource" />
</bean>
</property>
</bean>
<bean id="playerFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" value="classpath:data/footballjob/input/${player.file.name}" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer">
<bean
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="names"
value="ID,lastName,firstName,position,birthYear,debutYear" />
<bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="names" value="ID,lastName,firstName,position,birthYear,debutYear" />
</bean>
</property>
<property name="fieldSetMapper">
<bean
class="org.springframework.batch.sample.domain.football.internal.PlayerFieldSetMapper" />
<bean class="org.springframework.batch.sample.domain.football.internal.PlayerFieldSetMapper" />
</property>
</bean>
</property>
</bean>
<bean id="gameFileItemReader"
class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource"
value="classpath:data/footballjob/input/${games.file.name}" />
<bean id="gameFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" value="classpath:data/footballjob/input/${games.file.name}" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer">
<bean
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="names"
value="id,year,team,week,opponent,completes,attempts,passingYards,passingTd,interceptions,rushes,rushYards,receptions,receptionYards,totalTd" />
<bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="names" value="id,year,team,week,opponent,completes,attempts,passingYards,passingTd,interceptions,rushes,rushYards,receptions,receptionYards,totalTd" />
</bean>
</property>
<property name="fieldSetMapper">
<bean
class="org.springframework.batch.sample.domain.football.internal.GameFieldSetMapper" />
<bean class="org.springframework.batch.sample.domain.football.internal.GameFieldSetMapper" />
</property>
</bean>
</property>
</bean>
<bean id="playerSummarizationSource"
class="org.springframework.batch.item.database.JdbcCursorItemReader">
<bean id="playerSummarizationSource" class="org.springframework.batch.item.database.JdbcCursorItemReader">
<property name="dataSource" ref="dataSource" />
<property name="mapper">
<bean
class="org.springframework.batch.sample.domain.football.internal.PlayerSummaryMapper" />
<bean class="org.springframework.batch.sample.domain.football.internal.PlayerSummaryMapper" />
</property>
<property name="sql">
<value>
@@ -138,8 +120,7 @@
</aop:aspect>
</aop:config>
<bean id="footballProperties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<bean id="footballProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="properties">
<value>
games.file.name=games-small.csv
@@ -147,8 +128,7 @@
job.commit.interval=2
</value>
</property>
<property name="systemPropertiesModeName"
value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="order" value="1" />
</bean>

View File

@@ -1,70 +1,74 @@
<?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">
<description>
Showcases reading and writing of headers and footers. Copies header from input to output and adds a footer.
</description>
<bean id="headerFooterSample" parent="simpleJob">
<property name="steps">
<bean id="step1" parent="simpleStep" p:commitInterval="3">
<property name="streams">
<list>
<!--
explicit registration to enforce ordering (header needs to be
read before it can be written)
-->
<ref bean="reader" />
<ref bean="writer" />
</list>
</property>
<property name="listeners" ref="footerCallback" />
<property name="itemReader" ref="reader" />
<property name="itemWriter" ref="writer" />
</bean>
</property>
</bean>
<bean id="reader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" ref="inputResource" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer">
<bean
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="delimiter" value="," />
</bean>
</property>
<property name="fieldSetMapper">
<bean
class="org.springframework.batch.item.file.mapping.PassThroughFieldSetMapper" />
</property>
</bean>
</property>
<property name="skippedLinesCallback" ref="headerCopier" />
<property name="linesToSkip" value="1" />
</bean>
<bean id="writer" class="org.springframework.batch.item.file.FlatFileItemWriter">
<property name="resource" ref="outputResource" />
<property name="lineAggregator">
<bean
class="org.springframework.batch.item.file.transform.PassThroughLineAggregator" />
</property>
<property name="headerCallback" ref="headerCopier" />
<property name="footerCallback" ref="footerCallback" />
</bean>
<bean id="footerCallback" class="org.springframework.batch.sample.support.SummaryFooterCallback" />
<bean id="headerCopier"
class="org.springframework.batch.sample.support.HeaderCopyCallback" />
<bean id="inputResource" class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String"
value="data/headerFooterSample/input.txt" />
</bean>
<bean id="outputResource" class="org.springframework.core.io.FileSystemResource">
<constructor-arg type="java.lang.String"
value="target/test-outputs/headerFooterOutput.txt" />
</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"
xmlns:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-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">
<description>
Showcases reading and writing of headers and footers. Copies header from input to output and adds a footer.
</description>
<batch:job id="headerFooterSample">
<batch:step name="step1"/>
</batch:job>
<bean id="step1" parent="simpleStep" p:commitInterval="3">
<property name="streams">
<list>
<!--
explicit registration to enforce ordering (header needs to be
read before it can be written)
-->
<ref bean="reader" />
<ref bean="writer" />
</list>
</property>
<property name="listeners" ref="footerCallback" />
<property name="itemReader" ref="reader" />
<property name="itemWriter" ref="writer" />
</bean>
<bean id="reader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" ref="inputResource" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer">
<bean
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="delimiter" value="," />
</bean>
</property>
<property name="fieldSetMapper">
<bean
class="org.springframework.batch.item.file.mapping.PassThroughFieldSetMapper" />
</property>
</bean>
</property>
<property name="skippedLinesCallback" ref="headerCopier" />
<property name="linesToSkip" value="1" />
</bean>
<bean id="writer" class="org.springframework.batch.item.file.FlatFileItemWriter">
<property name="resource" ref="outputResource" />
<property name="lineAggregator">
<bean
class="org.springframework.batch.item.file.transform.PassThroughLineAggregator" />
</property>
<property name="headerCallback" ref="headerCopier" />
<property name="footerCallback" ref="footerCallback" />
</bean>
<bean id="footerCallback" class="org.springframework.batch.sample.support.SummaryFooterCallback" />
<bean id="headerCopier"
class="org.springframework.batch.sample.support.HeaderCopyCallback" />
<bean id="inputResource" class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String"
value="data/headerFooterSample/input.txt" />
</bean>
<bean id="outputResource" class="org.springframework.core.io.FileSystemResource">
<constructor-arg type="java.lang.String"
value="target/test-outputs/headerFooterOutput.txt" />
</bean>
</beans>

View File

@@ -1,29 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:batch="http://www.springframework.org/schema/batch"
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.5.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<description>Example for Hibernate integration.</description>
<bean id="hibernateJob" parent="simpleJob">
<!--
set restartable=false so that this job can be used by more than one
test
-->
<property name="restartable" value="false" />
<property name="steps">
<bean id="step1" parent="skipLimitStep">
<property name="skipLimit" value="5" />
<property name="itemReader" ref="hibernateItemReader" />
<property name="itemProcessor" ref="creditIncreaseProcessor" />
<property name="itemWriter" ref="hibernateCreditWriter" />
<property name="commitInterval" value="3" />
</bean>
</property>
<batch:job id="hibernateJob" restartable="false">
<batch:step name="step1"/>
</batch:job>
<bean id="step1" parent="skipLimitStep">
<property name="skipLimit" value="5" />
<property name="itemReader" ref="hibernateItemReader" />
<property name="itemProcessor" ref="creditIncreaseProcessor" />
<property name="itemWriter" ref="hibernateCreditWriter" />
<property name="commitInterval" value="3" />
</bean>
<bean id="creditIncreaseProcessor" class="org.springframework.batch.sample.domain.trade.internal.CustomerCreditIncreaseProcessor" />

View File

@@ -1,13 +1,15 @@
<?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"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- The tasklet used in this job will run in an infinite loop. This is useful for testing graceful shutdown from
multiple environments. -->
multiple environments. -->
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
@@ -16,29 +18,24 @@
</property>
</bean>
<bean id="infiniteLoopJob" parent="simpleJob">
<property name="jobParametersIncrementer">
<bean class="org.springframework.batch.sample.common.InfiniteLoopIncrementer" />
</property>
<property name="steps">
<!--bean id="step1" parent="taskletStep">
<property name="tasklet">
<bean id="module" class="org.springframework.batch.sample.tasklet.InfiniteLoopTasklet"/>
</property>
</bean-->
<bean id="infiniteStep" parent="simpleStep">
<property name="itemReader">
<bean id="reader" class="org.springframework.batch.sample.domain.trade.internal.GeneratingTradeItemReader">
<property name="limit" value="1000000" />
</bean>
</property>
<property name="itemWriter">
<bean id="writer" class="org.springframework.batch.sample.support.DummyItemWriter" />
</property>
<batch:job id="infiniteLoopJob"
incrementer="jobParametersIncrementer"
restartable="true">
<batch:step name="infiniteStep"/>
</batch:job>
<bean id="jobParametersIncrementer"
class="org.springframework.batch.sample.common.InfiniteLoopIncrementer" />
<bean id="infiniteStep" parent="simpleStep">
<property name="itemReader">
<bean id="reader" class="org.springframework.batch.sample.domain.trade.internal.GeneratingTradeItemReader">
<property name="limit" value="1000000" />
</bean>
</property>
<property name="itemWriter">
<bean id="writer" class="org.springframework.batch.sample.support.DummyItemWriter" />
</property>
</bean>
</beans>

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
@@ -7,20 +8,21 @@
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-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
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
<bean id="ioSampleJob" parent="simpleJob">
<property name="steps">
<bean id="step1" parent="simpleStep">
<property name="commitInterval" value="2"/>
<property name="itemReader" ref="itemReader"/>
<property name="itemWriter" ref="itemWriter" />
<property name="itemProcessor">
<bean class="org.springframework.batch.sample.domain.trade.internal.CustomerCreditIncreaseProcessor" />
</property>
</bean>
<batch:job id="ioSampleJob">
<batch:step name="step1"/>
</batch:job>
<bean id="step1" parent="simpleStep">
<property name="commitInterval" value="2"/>
<property name="itemReader" ref="itemReader"/>
<property name="itemWriter" ref="itemWriter" />
<property name="itemProcessor">
<bean class="org.springframework.batch.sample.domain.trade.internal.CustomerCreditIncreaseProcessor" />
</property>
</bean>

View File

@@ -1,33 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:batch="http://www.springframework.org/schema/batch"
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/batch
http://www.springframework.org/schema/batch/spring-batch-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="multilineJob" parent="simpleJob">
<property name="steps">
<bean id="step1" parent="simpleStep">
<property name="streams" ref="fileItemReader"/>
<property name="itemReader">
<bean
class="org.springframework.batch.sample.domain.multiline.AggregateItemReader">
<property name="itemReader"
ref="fileItemReader" />
</bean>
</property>
<property name="itemWriter">
<bean
class="org.springframework.batch.item.file.FlatFileItemWriter">
<property name="resource"
value="file:target/test-outputs/20070122.testStream.multilineStep.txt" />
<property name="lineAggregator">
<bean class="org.springframework.batch.item.file.transform.PassThroughLineAggregator"/>
</property>
</bean>
</property>
<batch:job id="multilineJob">
<batch:step name="step1"/>
</batch:job>
<bean id="step1" parent="simpleStep">
<property name="streams" ref="fileItemReader"/>
<property name="itemReader">
<bean
class="org.springframework.batch.sample.domain.multiline.AggregateItemReader">
<property name="itemReader"
ref="fileItemReader" />
</bean>
</property>
<property name="itemWriter">
<bean
class="org.springframework.batch.item.file.FlatFileItemWriter">
<property name="resource"
value="file:target/test-outputs/20070122.testStream.multilineStep.txt" />
<property name="lineAggregator">
<bean class="org.springframework.batch.item.file.transform.PassThroughLineAggregator"/>
</property>
</bean>
</property>
</bean>

View File

@@ -1,8 +1,10 @@
<?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"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
@@ -10,41 +12,41 @@
<import resource="multilineOrderOutputAggregators.xml" />
<import resource="multilineOrderIo.xml" />
<bean id="multilineOrderJob" parent="simpleJob">
<property name="steps">
<bean id="step1" parent="simpleStep">
<property name="streams">
<batch:job id="multilineOrderJob">
<batch:step name="step1"/>
</batch:job>
<bean id="step1" parent="simpleStep">
<property name="streams">
<list>
<ref bean="fileItemWriter" />
<ref bean="fileItemReader" />
</list>
</property>
<property name="itemReader">
<bean class="org.springframework.batch.sample.domain.order.internal.OrderItemReader">
<property name="fieldSetReader" ref="fileItemReader" />
<property name="headerMapper" ref="headerFieldSetMapper" />
<property name="customerMapper" ref="customerFieldSetMapper" />
<property name="addressMapper" ref="addressFieldSetMapper" />
<property name="billingMapper" ref="billingFieldSetMapper" />
<property name="itemMapper" ref="orderItemFieldSetMapper" />
<property name="shippingMapper" ref="shippingFieldSetMapper" />
</bean>
</property>
<property name="itemWriter" ref="fileItemWriter" />
<property name="itemProcessor">
<bean class="org.springframework.batch.item.support.CompositeItemProcessor">
<property name="itemProcessors">
<list>
<ref bean="fileItemWriter" />
<ref bean="fileItemReader" />
<bean class="org.springframework.batch.item.validator.ValidatingItemProcessor">
<constructor-arg ref="validator" />
</bean>
<bean class="org.springframework.batch.sample.domain.order.internal.OrderProcessor">
<property name="aggregators" ref="outputAggregators" />
</bean>
</list>
</property>
<property name="itemReader">
<bean class="org.springframework.batch.sample.domain.order.internal.OrderItemReader">
<property name="fieldSetReader" ref="fileItemReader" />
<property name="headerMapper" ref="headerFieldSetMapper" />
<property name="customerMapper" ref="customerFieldSetMapper" />
<property name="addressMapper" ref="addressFieldSetMapper" />
<property name="billingMapper" ref="billingFieldSetMapper" />
<property name="itemMapper" ref="orderItemFieldSetMapper" />
<property name="shippingMapper" ref="shippingFieldSetMapper" />
</bean>
</property>
<property name="itemWriter" ref="fileItemWriter" />
<property name="itemProcessor">
<bean class="org.springframework.batch.item.support.CompositeItemProcessor">
<property name="itemProcessors">
<list>
<bean class="org.springframework.batch.item.validator.ValidatingItemProcessor">
<constructor-arg ref="validator" />
</bean>
<bean class="org.springframework.batch.sample.domain.order.internal.OrderProcessor">
<property name="aggregators" ref="outputAggregators" />
</bean>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>

View File

@@ -1,118 +1,120 @@
<?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 id="parallelJob" parent="simpleJob">
<property name="steps">
<list>
<bean id="staging" parent="simpleStep">
<property name="commitInterval" value="2" />
<property name="startLimit" value="100" />
<property name="itemReader" ref="fileItemReader" />
<property name="itemProcessor">
<bean
class="org.springframework.batch.item.validator.ValidatingItemProcessor">
<constructor-arg ref="fixedValidator" />
</bean>
</property>
<property name="itemWriter">
<bean class="org.springframework.batch.sample.common.StagingItemWriter">
<property name="dataSource" ref="dataSource" />
<property name="incrementer">
<bean parent="incrementerParent">
<property name="incrementerName" value="BATCH_STAGING_SEQ" />
</bean>
</property>
</bean>
</property>
</bean>
<bean id="loading" parent="simpleStep">
<property name="taskExecutor">
<bean class="org.springframework.core.task.SimpleAsyncTaskExecutor" />
</property>
<property name="itemReader">
<bean class="org.springframework.batch.sample.common.StagingItemReader">
<property name="dataSource" ref="dataSource" />
</bean>
</property>
<property name="itemWriter">
<bean
class="org.springframework.batch.sample.domain.trade.internal.TradeWriter">
<property name="dao" ref="tradeDao" />
</bean>
</property>
</bean>
</list>
</property>
</bean>
<!-- INFRASTRUCTURE SETUP -->
<!--
This input source is injected into the test case to verify the output
- not used by the job at all
-->
<bean id="testItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource"
value="classpath:data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer" ref="fixedFileTokenizer" />
<property name="fieldSetMapper" ref="fieldSetMapper" />
</bean>
</property>
</bean>
<bean id="fileItemReader" parent="testItemReader"
autowire-candidate="false">
</bean>
<bean id="fixedFileTokenizer"
class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
<property name="names" value="ISIN, Quantity, Price, Customer" />
<property name="columns" value="1-12, 13-15, 16-20, 21-29" />
</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.domain.trade.internal.JdbcTradeDao">
<property name="dataSource" ref="dataSource" />
<property name="incrementer">
<bean parent="incrementerParent">
<property name="incrementerName" value="TRADE_SEQ" />
</bean>
</property>
</bean>
<bean id="fieldSetMapper"
class="org.springframework.batch.sample.domain.trade.internal.TradeFieldSetMapper" />
<aop:config>
<aop:aspect id="moduleLogging" ref="logAdvice">
<aop:after
pointcut="execution( * org.springframework.batch.item.ItemWriter+.write(Object)) and args(item)"
method="doStronglyTypedLogging" />
</aop:aspect>
</aop:config>
<?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"
xmlns:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-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">
<batch:job id="parallelJob">
<batch:step name="staging" next="loading"/>
<batch:step name="loading"/>
</batch:job>
<bean id="staging" parent="simpleStep">
<property name="commitInterval" value="2" />
<property name="startLimit" value="100" />
<property name="itemReader" ref="fileItemReader" />
<property name="itemProcessor">
<bean
class="org.springframework.batch.item.validator.ValidatingItemProcessor">
<constructor-arg ref="fixedValidator" />
</bean>
</property>
<property name="itemWriter">
<bean class="org.springframework.batch.sample.common.StagingItemWriter">
<property name="dataSource" ref="dataSource" />
<property name="incrementer">
<bean parent="incrementerParent">
<property name="incrementerName" value="BATCH_STAGING_SEQ" />
</bean>
</property>
</bean>
</property>
</bean>
<bean id="loading" parent="simpleStep">
<property name="taskExecutor">
<bean class="org.springframework.core.task.SimpleAsyncTaskExecutor" />
</property>
<property name="itemReader">
<bean class="org.springframework.batch.sample.common.StagingItemReader">
<property name="dataSource" ref="dataSource" />
</bean>
</property>
<property name="itemWriter">
<bean
class="org.springframework.batch.sample.domain.trade.internal.TradeWriter">
<property name="dao" ref="tradeDao" />
</bean>
</property>
</bean>
<!-- INFRASTRUCTURE SETUP -->
<!--
This input source is injected into the test case to verify the output
- not used by the job at all
-->
<bean id="testItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource"
value="classpath:data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer" ref="fixedFileTokenizer" />
<property name="fieldSetMapper" ref="fieldSetMapper" />
</bean>
</property>
</bean>
<bean id="fileItemReader" parent="testItemReader"
autowire-candidate="false">
</bean>
<bean id="fixedFileTokenizer"
class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
<property name="names" value="ISIN, Quantity, Price, Customer" />
<property name="columns" value="1-12, 13-15, 16-20, 21-29" />
</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.domain.trade.internal.JdbcTradeDao">
<property name="dataSource" ref="dataSource" />
<property name="incrementer">
<bean parent="incrementerParent">
<property name="incrementerName" value="TRADE_SEQ" />
</bean>
</property>
</bean>
<bean id="fieldSetMapper"
class="org.springframework.batch.sample.domain.trade.internal.TradeFieldSetMapper" />
<aop:config>
<aop:aspect id="moduleLogging" ref="logAdvice">
<aop:after
pointcut="execution( * org.springframework.batch.item.ItemWriter+.write(Object)) and args(item)"
method="doStronglyTypedLogging" />
</aop:aspect>
</aop:config>
</beans>

View File

@@ -1,33 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:batch="http://www.springframework.org/schema/batch"
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/batch http://www.springframework.org/schema/batch/spring-batch-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 id="restartSampleJob" parent="simpleJob">
<property name="steps">
<bean id="step1" parent="simpleStep">
<property name="streams" ref="fileItemReader" />
<property name="itemReader" ref="itemReader" />
<property name="itemProcessor">
<bean class="org.springframework.batch.item.validator.ValidatingItemProcessor">
<constructor-arg ref="fixedValidator" />
</bean>
</property>
<property name="itemWriter">
<bean
class="org.springframework.batch.sample.domain.trade.internal.TradeWriter">
<property name="dao" ref="tradeDao" />
</bean>
</property>
<property name="commitInterval" value="2" />
<batch:job id="restartSampleJob" restartable="true">
<batch:step name="step1"/>
</batch:job>
<bean id="step1" parent="simpleStep">
<property name="streams" ref="fileItemReader" />
<property name="itemReader" ref="itemReader" />
<property name="itemProcessor">
<bean class="org.springframework.batch.item.validator.ValidatingItemProcessor">
<constructor-arg ref="fixedValidator" />
</bean>
</property>
<property name="itemWriter">
<bean
class="org.springframework.batch.sample.domain.trade.internal.TradeWriter">
<property name="dao" ref="tradeDao" />
</bean>
</property>
<property name="commitInterval" value="2" />
</bean>
<!-- INFRASTRUCTURE SETUP -->

View File

@@ -1,22 +1,23 @@
<?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 id="retrySample" parent="simpleJob">
<property name="steps">
<bean id="step1" parent="simpleStep"
class="org.springframework.batch.core.step.item.FaultTolerantStepFactoryBean">
<property name="itemReader" ref="itemGenerator" />
<property name="itemWriter" ref="itemWriter" />
<property name="retryLimit" value="3" />
<property name="retryableExceptionClasses" value="java.lang.Exception" />
</bean>
</property>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:batch="http://www.springframework.org/schema/batch"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-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">
<batch:job id="retrySample">
<batch:step name="step1"/>
</batch:job>
<bean id="step1" parent="simpleStep"
class="org.springframework.batch.core.step.item.FaultTolerantStepFactoryBean">
<property name="itemReader" ref="itemGenerator" />
<property name="itemWriter" ref="itemWriter" />
<property name="retryLimit" value="3" />
<property name="retryableExceptionClasses" value="java.lang.Exception" />
</bean>
<bean id="itemGenerator" class="org.springframework.batch.sample.domain.trade.internal.GeneratingTradeItemReader">