Java Reference
In-Depth Information
<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.PropertyPlaceholderConfigureā€¯
>
<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>
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"
p:dataSource-ref="dataSource" p:transactionManager-ref="transactionManager" />
<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
</beans>
launch-context.xml has most of the elements discussed in the previous section and their
dependencies. It starts with a datasource. You use standard Spring configuration to configure a
datasource that Spring Batch uses to access the job repository and that is also available for any other
database access your batch processes may require. It's important to note that the database used by
Spring Batch for the JobRepository isn't required to be the same as the schema (or schemas) used for
business processing.
transactionManager also is configured in this file. Transaction processing is important in batch jobs
given that you process large volumes of data in chunks and each chunk being committed at once. This
again is a standard configuration using core Spring components.
Notice that you're using properties to specify values that may change from environment to
environment. After transactionManager , you configure Spring's PropertyPlaceholderConfigurer to
handle the population of these properties at runtime. You're using the batch.properties file to specify
the values, which is included in the source provided in the zip file.
Next you have jobRepository . This is the first Spring Batch component you're going to configure in
the launch-context.xml file. jobRepository is used to maintain the state of the job and each step for
Spring Batch. In this case, you're configuring the handle that the framework uses to perform CRUD
operations on the database. Chapter 5 goes over some advanced configurations of jobRepository
including changing schema prefixes, and so on. This example configuration provides its two required
dependencies: a datasource and a transaction manager.
The last piece of launch-context.xml you have here is the jobLauncher bean. As the previous section
said, the job launcher is the gateway into Spring Batch framework from an execution standpoint. It is
configured with the jobRepository as a dependency.
 
Search WWH ::




Custom Search