Java Reference
In-Depth Information
<beans:bean
class="org.springframework.batch.item.file.mapping.PassThroughLineMapper"/>
</beans:property>
</beans:bean>
<beans:bean id="outputWriter"
class="org.springframework.batch.item.file.FlatFileItemWriter">
<beans:property name="resource" ref="outputFile"/>
<beans:property name="lineAggregator">
<beans:bean
class="org.springframework.batch.item.file.transform.PassThroughLineAggregator"/>
</beans:property>
</beans:bean>
<step id="commitIntervalStep" abstract="true">
<tasklet>
<chunk commit-interval="15"/>
</tasklet>
</step>
<step id="copyStep" parent="commitIntervalStep">
<tasklet>
<chunk reader="inputReader" writer="outputWriter" />
</tasklet>
</step>
<job id="stepInheritanceJob">
<step id="step1" parent="copyStep" />
</job>
</beans:beans>
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
section.
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