Java Reference
In-Depth Information
configuration of the CallableTaskletAdapter bean shown in Listing 4-24, CallableTaskletAdapter
contains a single dependency: the callable object itself.
Listing 4-24. Using CallableTaskletAdapter
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns=""
<beans:import resource="../launch-context.xml"/>
<beans:bean id="callableObject"
<beans:bean id="callableTaskletAdapter"
<beans:property name="callable" ref="callableObject"/>
<job id="callableJob">
<step id="step1">
<tasklet ref="callableTaskletAdapter"/>
One thing to note with CallableTaskletAdapter is that although the tasklet is executed in a different
thread than the step itself, this doesn't parallelize your step execution. The execution of this step won't
be considered complete until the Callable object returns a valid RepeatStatus object. Until this step is
considered complete, no other steps in the flow in which this step is configured will execute. You see
how to parallelize processing in a number of ways, including executing steps in parallel, later in this
The next Tasklet implementation is
org.springframework.batch.core.step.tasklet.MethodInvokingTaskletAdapter . This class is similar to a
number of utility classes available in the Spring framework. It allows you to execute a preexisting
method on another class as the step of your job. Say for example you already have a service that does a
piece of logic that you want to run once in your batch job. Instead of writing an implementation of the
Tasklet interface that really just wraps that method call, you can use MethodInvokingTaskletAdapter to
call the method. Listing 4-25 shows an example of the configuration for MethodInvokingTaskletAdapter .
Search WWH ::

Custom Search