Java Reference
In-Depth Information
<beans:bean id="outputWriter"
<beans:property name="resource" ref="outputFile"/>
<beans:property name="lineAggregator">
<step id="commitIntervalStep" abstract="true">
<chunk commit-interval="15"/>
<step id="copyStep" parent="commitIntervalStep">
<chunk reader="inputReader" writer="outputWriter" />
<job id="stepInheritanceJob">
<step id="step1" parent="copyStep" />
In Listing 4-33, commitIntervalStep is an abstract step that is used to configure the commit interval
for any step that extends this step. You configure the required elements of a step in the step that extends
the abstract step, copyStep . Here you specify a reader and writer. copyStep has the same commit-interval
of 15 that commitIntervalStep has, without the need to repeat the configuration.
Step inheritance allows you to configure common attributes that can be reused from step to step as
well as structure your XML configuration in a maintainable way. The last example of this section used a
couple of attributes that were chunk specific. To better understand them, let's go over how you can use
the different features that Spring Batch provides in its chunk-based processing.
Chunk-Size Configuration
Because chunk-based processing is the foundation of Spring Batch 2, it's important to understand how
to configure its various options to take full advantage of this important feature. This section covers the
two options for configuring the size of a chunk: a static commit count and a CompletionPolicy
implementation. All other chunk configuration options relate to error handling and are discussed in that
To start looking at chunk configuration, Listing 4-34 has a basic example of nothing more than a
reader, writer, and commit-interval configured. The reader is an implementation of the ItemReader
interface, and the writer an implementation of ItemWriter . Each of these interfaces has its own
dedicated chapter later in the topic, so this section doesn't go into detail about them. All you need to
Search WWH ::

Custom Search