Java Reference
In-Depth Information
Listing 9-74. Reading in the customerWithEmail.csv File
...
<beans:bean id="customerFile"
class="org.springframework.core.io.FileSystemResource" scope="step">
<beans:constructor-arg value="#{jobParameters[customerFile]}"/>
</beans:bean>
<beans:bean id="customerFileReader"
class="org.springframework.batch.item.file.FlatFileItemReader">
<beans:property name="resource" ref="customerFile"/>
<beans:property name="lineMapper">
<beans:bean
class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<beans:property name="lineTokenizer">
<beans:bean class="org.springframework.batch.item.file.transform.
DelimitedLineTokenizer">
<beans:property name="names"
value="firstName,middleInitial,lastName,address,city,state,zip,
email"/>
<beans:property name="delimiter" value=","/>
</beans:bean>
</beans:property>
<beans:property name="fieldSetMapper">
<beans:bean class="org.springframework.batch.item.file.mapping.
BeanWrapperFieldSetMapper">
<beans:property name="prototypeBeanName" value="customer"/>
</beans:bean>
</beans:property>
</beans:bean>
</beans:property>
</beans:bean>
<beans:bean id="customer" class="com.apress.springbatch.chapter9.Customer"
scope="prototype"/>
...
Nothing in Listing 9-74 should be unfamiliar. You're using the same input file you used in the
previous examples in this chapter. The configuration consists of the file reference ( Resource ), the
configuration of the FlatFileItemReader using DelimitedLineTokenizer and BeanWrapperFieldSetMapper
to read the file, and a reference to the Customer bean to create them as required.
On the output side, you need to create three ItemWriters: the XML writer and its dependencies, the
JDBC writer and its dependencies, and the CompositeItemWriter that wraps both of the other writers.
Listing 9-75 shows the configuration for the output of this step as well as the configuration for the step
and job.
Listing 9-75. Output, Step, and Job Configuration
...
<beans:bean id="outputFile"
class="org.springframework.core.io.FileSystemResource" scope="step">
Search WWH ::




Custom Search