Make ModularBatchConfiguration extend SimpleBatchConfiguration

This change makes the added value of ModularBatchConfiguration
compared to SimpleBatchConfiguration more visible.
This commit is contained in:
Mahmoud Ben Hassine
2022-05-15 01:21:10 +02:00
parent 31af573153
commit a34a464763
2 changed files with 4 additions and 33 deletions

View File

@@ -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.
*

View File

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