Java Reference
In-Depth Information
in an ordered list of properties to extract from the item along with the target object and method to be
called. The list you pass in in the same order as the parameters required for the property; Spring does
support dot notation ( , for example) as well as index properties ( e-mail[5] ). Just like the
ItemWriterAdapter , this ItemWriter implementation also exposes an arguments property that isn't used
because the arguments are extracted by the writer dynamically. Listing 9-45 shows the job updated to
call the logAddress method instead of handling the entire Customer item.
Listing 9-45. formatJob Configured to Call the logAddress Method on CustomerServiceImpl
<beans:bean id="parameterizedItemWriterAdapter"
<beans:property name="targetObject" ref="customerService"/>
<beans:property name="targetMethod" value="logAddress"/>
<beans:property name="fieldsUsedAsTargetMethodArguments"
<step id="formatFileStep">
<chunk reader="customerFileReader"
writer="parameterizedItemWriterAdapter" commit-interval="10"/>
<job id="formatJob">
<step id="step1" parent="formatFileStep"/>
When you run the job, the output of it consists of a sentence written to System.out with a formatted
address. Listing 9-46 shows a sample of the output you can expect.
Listing 9-46. Output of formatJob Using PropertyExtractingDelegatingItemWriter
2011-03-10 22:14:46,744 DEBUG main
[] - <Repeat operation
about to start at count=9>
2011-03-10 22:14:46,744 DEBUG main
[] - <Repeat operation
about to start at count=10>
2011-03-10 22:14:46,745 DEBUG main
[] - <Repeat is
complete according to policy and result value.>
I just saved the address:
5570 Isabella Ave
St. Louis, IL
I just saved the address:
4686 Mt. Lee Drive
Search WWH ::

Custom Search