Java Reference
In-Depth Information
<beans:bean id="transactionDao"
<beans:property name="dataSource" ref="dataSource"/>
<beans:bean id="transactionApplierProcessor"
<beans:property name="transactionDao" ref="transactionDao"/>
<beans:bean id="accountSummaryUpdater"
<beans:property name="assertUpdates" value="true" />
<beans:property name="itemSqlParameterSourceProvider">
<beans:bean class="org.springframework.batch.item.database.
BeanPropertyItemSqlParameterSourceProvider" />
<beans:property name="sql" value="UPDATE ACCOUNT_SUMMARY SET
CURRENT_BALANCE = :currentBalance WHERE ACCOUNT_NUMBER = :accountNumber" />
<step id="applyTransactionsStep">
<chunk reader="accountSummaryReader"
writer="accountSummaryUpdater" commit-interval="100"/>
The second step of this job applies the transactions to the user's account. The configuration for this
step begins with the ItemReader you use to read the account summary records from the database. As
each item is read, you update the currentBalance field with each of the transactions you imported in the
previous step in the transactionApplierProcessor . This ItemProcessor uses a data access object (DAO)
to look up the transactions for the account as they're processed. Finally, the account is updated with the
new currentBalance value using the accountSummaryUpdater ItemWriter. The configuration for the step
itself links the ItemReader, ItemProcessor, and ItemWriter together at the end of Listing 6-24.
The last step in the job, generateAccountSummaryStep , consists of the same accountSummaryReader
configured in Listing 6-24, but it adds a new ItemWriter that writes the summary file. Listing 6-25 shows
the configuration of the new ItemWriter and the related step.
Listing 6-25. generateAccountSummaryStep Configuration
<beans:bean id="summaryFile"
class="" scope="step">
<beans:constructor-arg value="#{jobParameters[summaryFile]}"/>
<beans:bean id="accountSummaryWriter"
Search WWH ::

Custom Search