diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java index 14fc442faa..6622eb5719 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java @@ -23,6 +23,8 @@ import javax.sql.DataSource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.batch.core.configuration.annotation.BatchConfigurer; +import org.springframework.batch.core.explore.JobExplorer; +import org.springframework.batch.core.explore.support.JobExplorerFactoryBean; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.launch.support.SimpleJobLauncher; import org.springframework.batch.core.repository.JobRepository; @@ -36,6 +38,7 @@ import org.springframework.transaction.PlatformTransactionManager; * Basic {@link BatchConfigurer} implementation. * * @author Dave Syer + * @author Andy Wilkinson */ @Component public class BasicBatchConfigurer implements BatchConfigurer { @@ -52,6 +55,8 @@ public class BasicBatchConfigurer implements BatchConfigurer { private JobLauncher jobLauncher; + private JobExplorer jobExplorer; + /** * Create a new {@link BasicBatchConfigurer} instance. * @param dataSource the underlying data source @@ -86,18 +91,31 @@ public class BasicBatchConfigurer implements BatchConfigurer { return this.jobLauncher; } + @Override + public JobExplorer getJobExplorer() throws Exception { + return this.jobExplorer; + } + @PostConstruct public void initialize() { try { this.transactionManager = createTransactionManager(); this.jobRepository = createJobRepository(); this.jobLauncher = createJobLauncher(); + this.jobExplorer = createJobExplorer(); } catch (Exception ex) { throw new IllegalStateException("Unable to initialize Spring Batch", ex); } } + private JobExplorer createJobExplorer() throws Exception { + JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean(); + jobExplorerFactoryBean.setDataSource(this.dataSource); + jobExplorerFactoryBean.afterPropertiesSet(); + return jobExplorerFactoryBean.getObject(); + } + private JobLauncher createJobLauncher() throws Exception { SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); jobLauncher.setJobRepository(getJobRepository()); diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java index c4d52764b5..02c8e92eb2 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java @@ -248,8 +248,8 @@ public class BatchAutoConfigurationTests { return launcher; } - @Bean - public JobExplorer jobExplorer() throws Exception { + @Override + public JobExplorer getJobExplorer() throws Exception { MapJobExplorerFactoryBean explorer = new MapJobExplorerFactoryBean( this.factory); explorer.afterPropertiesSet(); diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunnerTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunnerTests.java index 8d36b08de7..9442d06da4 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunnerTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunnerTests.java @@ -39,7 +39,6 @@ import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.task.SyncTaskExecutor; import org.springframework.transaction.PlatformTransactionManager; @@ -177,8 +176,8 @@ public class JobLauncherCommandLineRunnerTests { return launcher; } - @Bean - public JobExplorer jobExplorer() throws Exception { + @Override + public JobExplorer getJobExplorer() throws Exception { return new MapJobExplorerFactoryBean(this.jobRepositoryFactory).getObject(); } } diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index b3d835d881..3624ef5cfd 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -98,7 +98,7 @@ 0.7-groovy-2.0 4.0.5.RELEASE 1.3.5.RELEASE - 3.0.0.RELEASE + 3.0.1.RELEASE Dijkstra-SR1 0.14.0.RELEASE 4.0.2.RELEASE