Java Reference
In-Depth Information
<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"
p:dataSource-/ref="dataSource" p:transactionManager-ref="transactionManager" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${batch.jdbc.driver}" />
<property name="url" value="${batch.jdbc.url}" />
<property name="username" value="${batch.jdbc.user}" />
<property name="password" value="${batch.jdbc.password}" />
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
lazy-init="true">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="placeholderProperties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:batch.properties" />
<property name="systemPropertiesModeName"
value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="order" value="1" />
</bean>
</beans>
A quick walkthrough of this file shows that it looks like a normal applicationContext.xml file for
Spring because … it's a normal applicationContext.xml file from Spring. You begin with the standard
XML namespace declarations for the file. From there, you define six beans:
jobExplorer : This bean is used by Spring Batch to access the JobRepository in a
read-only mode. The JobExplorer's only dependency is a datasource.
JobLauncher : In order to run a job with Spring Batch, a JobLauncher is required.
Here you keep things simple and use the SimpleJobLauncher that is provided by
the framework. Although you could administer this job in a number of ways, in
most enterprises jobs are administered by an external scheduler, so there is no
reason to get fancy here. The JobLauncher has the JobRepository as its only
dependency.
JobRepository : The JobRepository provides CRUD operations for Spring Batch to
persist state and other metadata about each job run. Because you use a persistent
JobRepository, it requires a datasource and a transaction manager for its
processing.
 
Search WWH ::




Custom Search