Fixed manual wiring of JsrJobOperator

While the JSR-352 provides only one way to access the JobOperator
(BatchRuntime.getJobOperator()), it is useful for testing and embedding
to be able to wire your own JsrJobOperator instance.  This commit
addresses previous issues with using the constructor that provided that
functionality.

Note: This is a breaking change in that there is a new parameter on the
non-default constructor (adding a PlatformTransactionManager reference).
Users using the JsrJobOperator through the BatchRuntime as previously
mentioned should not be impacted.  Since this is the *only* method
perscribed by the JSR to consume that class, it is not expected to have
a large impact.

This fix partially addresses BATCH-2290.
This commit is contained in:
Michael Minella
2014-12-22 16:40:10 -06:00
parent 34fc9a0660
commit c10469367f
4 changed files with 147 additions and 41 deletions

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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.xsd">
<bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager"/>
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
<property name="transactionManager" ref="transactionManager"/>
</bean>
<bean id="jobExplorer" class="org.springframework.batch.core.explore.support.MapJobExplorerFactoryBean">
<property name="repositoryFactory" ref="&amp;jobRepository"/>
</bean>
<bean id="jobParametersConverter" class="org.springframework.batch.core.converter.DefaultJobParametersConverter"/>
<bean id="jsrJobOperator" class="org.springframework.batch.core.jsr.launch.JsrJobOperator">
<constructor-arg ref="jobExplorer"/>
<constructor-arg ref="jobRepository"/>
<constructor-arg ref="jobParametersConverter"/>
<constructor-arg ref="transactionManager"/>
</bean>
</beans>