Java Reference
In-Depth Information
<beans:property name="command" value="touch temp.txt" />
<beans:property name="timeout" value="5000" />
<beans:property name="interruptOnCancel" value="true" />
<beans:property name="workingDirectory"
value="/Users/mminella/spring-batch" />
<beans:property name="systemProcessExitCodeMapper"
<beans:property name="terminationCheckInterval" value="5000" />
<beans:property name="taskExecutor" ref="taskExecutor" />
<beans:property name="environmentParams"
value="JAVA_HOME=/java,BATCH_HOME=/Users/batch" />
<job id="systemCommandJob">
<step id="step1">
<tasklet ref="robustFileDeletionCommand" />
Listing 4-28 includes five more optional parameters in the configuration:
workingDirectory : This is the directory from which to execute the command. In
this example, it's the equivalent of executing cd ~/spring-batch before
executing the actual command.
systemProcessExitCodeMapper : System codes may mean different things
depending on the command you're executing. This property allows you to use
an implementation of the
interface to map what system-return codes go with what Spring Batch status
values. Spring provides two implementations of this interface by default:
tCodeMapper , which allows you to configure the mapping in your XML
configuration, and
apper , which returns ExitStatus.FINISHED if the return code was 0 and
ExitStatus.FAILED if it was anything else.
terminationCheckInterval : Because the system command is executed in an
asynchronous way by default, the tasklet checks periodically to see if it has
completed. By default, this value is set to one second, but you can configure it
to any value you wish in milliseconds.
taskExecutor : This allows you to configure your own TaskExecutor to execute
the system command. You're highly discouraged from configuring a
synchronous task executor due to the potential of locking up your job if the
system command causes problems.
environmentParams : This is a list of environment parameters you can set prior to
the execution of your command.
You've seen over the previous section that many different tasklet types are available in Spring Batch.
Before moving off the topic, however, there is one other tasklet type to discuss: the tasklet step.
Search WWH ::

Custom Search