Java Reference
In-Depth Information
}
}
The LineAggregator implementation in Listing 7-23 is quite simple. It takes an item, determines its
type, and passes the item to the appropriate LineAggregator implementation based upon the type. The
configuration for the previous LineAggregator is shown in Listing 7-24.
Listing 7-24. outputWriter Configuration
<beans:bean id="outputFile"
class="org.springframework.core.io.FileSystemResource" scope="step">
<beans:constructor-arg value="#{jobParameters[outputFile]}"/>
</beans:bean>
<beans:bean id="outputWriter"
class="org.springframework.batch.item.file.FlatFileItemWriter">
<beans:property name="resource" ref="outputFile" />
<beans:property name="lineAggregator">
<beans:bean
class="com.apress.springbatch.chapter7.CustomerLineAggregator">
<beans:property name="customerLineAggregator"
ref="customerLineAggregator" />
<beans:property name="transactionLineAggregator"
ref="transactionLineAggregator" />
</beans:bean>
</beans:property>
</beans:bean>
<beans:bean id="customerLineAggregator"
class="org.springframework.batch.item.file.transform.
FormatterLineAggregator">
<beans:property name="fieldExtractor">
<beans:bean class="org.springframework.batch.item.file.transform.
BeanWrapperFieldExtractor">
<beans:property name="names" value="firstName,middleInitial,lastName,
address,city,state,zip" />
</beans:bean>
</beans:property>
<beans:property name="format" value="%s %s. %s, %s, %s %s %s" />
</beans:bean>
<beans:bean id="transactionLineAggregator" class="org.springframework.batch.
item.file.transform.FormatterLineAggregator">
<beans:property name="fieldExtractor">
<beans:bean class="org.springframework.batch.item.file.transform.
BeanWrapperFieldExtractor">
<beans:property name="names" value="accountNumber,amount,dateString" />
</beans:bean>
</beans:property>
<beans:property name="format" value="%s had a transaction of %.2f on %s" />
Search WWH ::




Custom Search