to map fields in the FieldSet to fields in the domain object by name (the Customer object will have a
getFirstName() and a setFirstName(String name) , etc). The only thing you need to supply for the
BeanWrapperFieldSetMapper is a reference to the bean it will be using, in your case it is the reference to
the customer bean.
Note The FixedLengthTokenizer doesn't trim any leading or trailing characters (spaces, zeros, etc) within each
field. To do this, you'll have to implement your own LineTokenizer or you can trim in your own FieldSetMapper.
To put your reader to use, you need to configure your step and job. You will also need to configure a
writer so that you can see that everything works. You will be covering writers in depth in the next chapter
so you can keep the writer for this example simple. Listing 7-4 shows how to configure a simple writer to
output the domain objects to a file.
Listing 7-4. A Simple Writer
<beans:property name="resource" ref="outputFile" />
<beans:property name="names" value="firstName,middleInitial,
<beans:property name="format" value=" %s %s. %s, %s %s, %s %s %s" />
Looking at the output file resource and the writer in Listing 7-4, you can see a pattern between the
readers and writers. The writer has two dependencies: the file resource to write to and a lineAggregator.
The lineAggregator is used to take an object and convert it to the string that will be written to the file.
Your job configuration is very simple. As shown in Listing 7-5, a simple step that consists of the
reader and writer with a commit count of 10 records is all you need. Your job uses that single step.