Skip to content

Commit 6a5de97

Browse files
author
Mattias Jiderhamn
committed
Allow setting transactionManager of DefaultBatchConfigurer
1 parent 164bf17 commit 6a5de97

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/DefaultBatchConfigurer.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,15 @@ public class DefaultBatchConfigurer implements BatchConfigurer {
4949
@Autowired(required = false)
5050
public void setDataSource(DataSource dataSource) {
5151
this.dataSource = dataSource;
52-
this.transactionManager = new DataSourceTransactionManager(dataSource);
52+
}
53+
54+
protected DataSource getDataSource() {
55+
return dataSource;
56+
}
57+
58+
@Autowired(required = false)
59+
public void setTransactionManager(PlatformTransactionManager transactionManager) {
60+
this.transactionManager = transactionManager;
5361
}
5462

5563
protected DefaultBatchConfigurer() {}
@@ -96,6 +104,10 @@ public void initialize() {
96104
jobExplorerFactory.afterPropertiesSet();
97105
this.jobExplorer = jobExplorerFactory.getObject();
98106
} else {
107+
if(this.transactionManager == null) {
108+
this.transactionManager = new DataSourceTransactionManager(dataSource);
109+
}
110+
99111
this.jobRepository = createJobRepository();
100112

101113
JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();

0 commit comments

Comments
 (0)