Java Reference
In-Depth Information
</beans:bean>
<beans:bean id="customerLineTokenizer"
class="org.springframework.batch.item.file.transform.
DelimitedLineTokenizer">
<beans:property name="names" value="prefix,firstName,middleInitial,
lastName,address,city,state,zip"/>
<beans:property name="delimiter" value=","/>
</beans:bean>
<beans:bean id="transactionLineTokenizer"
class="org.springframework.batch.item.file.transform.
DelimitedLineTokenizer">
<beans:property name="names"
value="prefix,accountNumber,transactionDate,amount"/>
<beans:property name="delimiter" value=","/>
</beans:bean>
<beans:bean id="customerFieldSetMapper"
class="org.springframework.batch.item.file.mapping.
BeanWrapperFieldSetMapper">
<beans:property name="prototypeBeanName" value="customer"/>
<beans:property name="strict" value="false"/>
</beans:bean>
<beans:bean id="transactionFieldSetMapper"
class="com.apress.springbatch.chapter7.TransactionFieldSetMapper"/>
<beans:bean id="customer" class="com.apress.springbatch.chapter7.Customer"
scope="prototype"/>
The other change you need to make is to the CustomerFileReader code. Previously, you were able to
use the ItemStreamReader interface as what you implemented and the delegate's type. However, that
won't be specific enough this time around. Instead, you are going to need to use one of the
ItemStreamResource's sub interfaces. The ResourceAwareItemReaderItemStream interface is for any
ItemReader that reads its input from resources. The reason you will want to make the two changes is that
you will need to be able to inject multiple Resources into the ItemReader.
By implementing org.springframework.batch.item.file.ResourceAwareItemStreamItemReader , you
will be required to add one additional method: setResource . Like the open , close and update methods of
the ItemStreamReader interface, you will just be calling the setResource method on the delegate in your
implementation. The other change you need to make is to have your delegate be of the type
ResourceAwareItemStreamItemReader. Since you are using the FlatFileItemReader as your delegate,
you won't need to use a different ItemReader as the delegate. The updated code is listed in Listing 7-32.
 
Search WWH ::




Custom Search