https://code.google.com/p/springbatch-in-action/source/browse/trunk/sbia/ch07/src/test/resources/com/manning/sbia/ch07/custom/JobCompositeItemWriterTest-context.xml?r=158
<?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:batch="http://www.springframework.org/schema/batch" |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd |
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd"> |
<import resource="classpath:com/manning/sbia/ch07/test-batch-infrastructure-context.xml" /> |
<import resource="classpath:com/manning/sbia/ch07/test-batch-reader-context.xml" /> |
<job id="writeProductsJob" xmlns="http://www.springframework.org/schema/batch"> |
<step id="readWrite"> |
<tasklet> |
<chunk reader="productItemReader" writer="productItemWriter" commit-interval="3" /> |
</tasklet> |
</step> |
</job> |
|
<bean id="productItemWriter" class="org.springframework.batch.item.support.CompositeItemWriter"> |
<property name="delegates"> |
<list> |
<ref local="delimitedProductItemWriter"/> |
<ref local="fixedWidthProductItemWriter"/> |
</list> |
</property> |
</bean> |
<bean id="delimitedProductItemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter"> |
<property name="resource" value="file:target/outputs/composite-pipeseparator.txt"/> |
<property name="lineAggregator"> |
<bean class="org.springframework.batch.item.file.transform.DelimitedLineAggregator"> |
<property name="delimiter" value="|" /> |
<property name="fieldExtractor"> |
<bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor"> |
<property name="names" value="id,price,name" /> |
</bean> |
</property> |
</bean> |
</property> |
</bean> |
<bean id="fixedWidthProductItemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter"> |
<property name="resource" value="file:target/outputs/composite-beanwrapperextractor.txt"/> |
<property name="lineAggregator"> |
<bean class="org.springframework.batch.item.file.transform.FormatterLineAggregator"> |
<property name="fieldExtractor"> |
<bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor"> |
<property name="names" value="id,price,name" /> |
</bean> |
</property> |
<property name="format" value="%-9s%6.2f%-30s" /> |
</bean> |
</property> |
</bean> |
</beans> |