Java Reference
In-Depth Information
launch-context.xml consists mostly of the usual Spring Batch suspects, as shown in Listing 6-12.
You need to add just three beans to make the Quartz interaction work: jobDetail , cronTrigger , and
schedule .
Listing 6-12. Updates to launch-context.xml
<bean id="jobDetail"
<property name="jobClass"
<property name="jobDataAsMap">
<entry key="jobName" value="deleteFilesJob" />
<entry key="jobLocator" value-ref="jobRegistry" />
<entry key="jobLauncher" value-ref="jobLauncher" />
<entry key="jobExplorer" value-ref="jobExplorer"/>
<entry key="jobParameters">
<entry key="path" value="${batch.temp.dir}" />
<entry key="age" value="${batch.temp.age}" />
<bean id="cronTrigger"
<property name="jobDetail" ref="jobDetail" />
<property name="cronExpression" value="0/10 * * * * ?" />
<bean id="schedule"
<property name="triggers" ref="cronTrigger"/>
The first bean of consequence in launch-context.xml for the Quartz example is the jobDetail bean.
Here is where you configure SpringBatchQuartzJobLauncher . It's important to note how the relationship
between Spring's JobDetailBean and the SpringBatchQuartzJobLauncher bean is used. You configure a
JobDetailBean as a Spring bean in launch-context.xml . Each time your Quartz job is executed, the
JobDetailBean creates a new instance of SpringBatchQuartzJobLauncher . When configuring the
JobDetailBean , jobDetail , you set two properties:
jobClass : This is the class that is instantiated and executed each time the Quartz
job runs.
Search WWH ::

Custom Search