Upgrade to Spring Batch 3.0.1

Due to a mistake in Spring Batch 3.0.0 it has been necessary to
introduce a breaking API change (the addition of
BatchConfigurer.getJobExplorer()) in the 3.0.1 release. This commit
updates Boot to use 3.0.1 and modifies the Batch auto-configuration
and associated tests to implement the new method.
pull/1209/merge
Andy Wilkinson 11 years ago committed by Phillip Webb
parent f7b7b1c8cb
commit 6a0eb90007

@ -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());

@ -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();

@ -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();
}
}

@ -98,7 +98,7 @@
<spock.version>0.7-groovy-2.0</spock.version>
<spring.version>4.0.5.RELEASE</spring.version>
<spring-amqp.version>1.3.5.RELEASE</spring-amqp.version>
<spring-batch.version>3.0.0.RELEASE</spring-batch.version>
<spring-batch.version>3.0.1.RELEASE</spring-batch.version>
<spring-data-releasetrain.version>Dijkstra-SR1</spring-data-releasetrain.version>
<spring-hateoas.version>0.14.0.RELEASE</spring-hateoas.version>
<spring-integration.version>4.0.2.RELEASE</spring-integration.version>

Loading…
Cancel
Save