Java Reference
In-Depth Information
public class JMXJobRunner {
private JobOperator operator;
public void runJob(String name) throws NoSuchJobException,
JobInstanceAlreadyExistsException,
JobParametersInvalidException {
operator.start(name, null);
}
public void setOperator(JobOperator operator) {
this.operator = operator;
}
}
In Listing 5-12, you use the JobOperator.start method to launch a job with the name provided and
no parameters; the job is configured within the previously loaded ApplicationContext . With the
JMXJobRunner and Batch classes written, the only thing left is to wire them up with Spring. All of the
configuration for these elements is in launch-context.xml , as shown in Listing 5-13.
Listing 5-13. launch-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:beans=" http://www.springframework.org/schema/beans"
xmlns=" http://www.springframework.org/schema/batch"
xmlns:p=" http://www.springframework.org/schema/p"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.1.xsd">
<beans:bean id="jobOperator"
class="org.springframework.batch.core.launch.support.SimpleJobOperator"
p:jobLauncher-ref="jobLauncher" p:jobExplorer-ref="jobExplorer"
p:jobRepository-ref="jobRepository" p:jobRegistry-ref="jobRegistry" />
<beans:bean id="jobExplorer"
class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean"
p:dataSource-ref="dataSource" />
<beans:bean id="taskExecutor"
class="org.springframework.core.task.SimpleAsyncTaskExecutor" />
<beans:bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<beans:property name="jobRepository" ref="jobRepository" />
<beans:property name="taskExecutor" ref="taskExecutor" />
</beans:bean>
<job-repository id="jobRepository"
data-source="dataSource" transaction-manager="transactionManager" />
 
Search WWH ::




Custom Search