Make ModularBatchConfiguration extend SimpleBatchConfiguration
This change makes the added value of ModularBatchConfiguration compared to SimpleBatchConfiguration more visible.
This commit is contained in:
@@ -30,8 +30,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
/**
|
||||
* Base {@code Configuration} class providing common structure for enabling and using Spring Batch. Customization is
|
||||
* available by implementing the {@link BatchConfigurer} interface.
|
||||
* Base {@code Configuration} class providing common structure for enabling and using Spring Batch.
|
||||
* Customization is available by implementing the {@link BatchConfigurer} interface.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
@@ -39,39 +39,10 @@ import org.springframework.transaction.PlatformTransactionManager;
|
||||
* @see EnableBatchProcessing
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class ModularBatchConfiguration extends AbstractBatchConfiguration {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
@Autowired(required = false)
|
||||
private Collection<BatchConfigurer> configurers;
|
||||
public class ModularBatchConfiguration extends SimpleBatchConfiguration {
|
||||
|
||||
private AutomaticJobRegistrar registrar = new AutomaticJobRegistrar();
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public JobRepository jobRepository() throws Exception {
|
||||
return getConfigurer(configurers).getJobRepository();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public JobLauncher jobLauncher() throws Exception {
|
||||
return getConfigurer(configurers).getJobLauncher();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformTransactionManager transactionManager() throws Exception {
|
||||
return getConfigurer(configurers).getTransactionManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public JobExplorer jobExplorer() throws Exception {
|
||||
return getConfigurer(configurers).getJobExplorer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link AutomaticJobRegistrar} bean.
|
||||
*
|
||||
|
||||
@@ -47,7 +47,7 @@ import org.springframework.transaction.PlatformTransactionManager;
|
||||
public class SimpleBatchConfiguration extends AbstractBatchConfiguration {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
protected ApplicationContext context;
|
||||
|
||||
@Autowired(required = false)
|
||||
private Collection<BatchConfigurer> configurers;
|
||||
|
||||
Reference in New Issue
Block a user