Skip to content

Commit 90d8206

Browse files
committed
Upgraded to Spring Boot 2.6.7
1 parent 85a8682 commit 90d8206

File tree

5 files changed

+143
-207
lines changed

5 files changed

+143
-207
lines changed

batch-web-spring-boot-autoconfigure/src/main/java/de/codecentric/batch/configuration/BaseConfiguration.java

Lines changed: 0 additions & 93 deletions
This file was deleted.

batch-web-spring-boot-autoconfigure/src/main/java/de/codecentric/batch/configuration/BatchWebAutoConfiguration.java

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package de.codecentric.batch.configuration;
1818

19+
import org.springframework.batch.core.configuration.JobRegistry;
1920
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
2021
import org.springframework.batch.core.converter.DefaultJobParametersConverter;
2122
import org.springframework.batch.core.converter.JobParametersConverter;
@@ -67,73 +68,72 @@
6768
@PropertySource("classpath:batch-web-spring-boot-autoconfigure.properties")
6869
@AutoConfigureAfter({ MetricsAutoConfiguration.class })
6970
@Import({ WebConfig.class, TaskExecutorBatchConfiguration.class, AutomaticJobRegistrarConfiguration.class,
70-
BaseConfiguration.class, Jsr352BatchConfiguration.class, MetricsConfiguration.class,
71-
TaskExecutorConfiguration.class })
71+
Jsr352BatchConfiguration.class, MetricsConfiguration.class, TaskExecutorConfiguration.class })
7272
@EnableConfigurationProperties({ BatchConfigurationProperties.class })
7373
public class BatchWebAutoConfiguration implements ApplicationListener<ContextRefreshedEvent>, Ordered {
7474

75-
@Autowired
76-
private BatchConfigurationProperties batchConfig;
77-
78-
@Autowired
79-
private BaseConfiguration baseConfig;
80-
81-
// ################### Listeners automatically added to each job #################################
82-
83-
@Bean
84-
public LoggingListener loggingListener() {
85-
return new LoggingListener();
86-
}
87-
88-
@Bean
89-
public LoggingAfterJobListener loggingAfterJobListener() {
90-
return new LoggingAfterJobListener();
91-
}
92-
93-
@Bean
94-
public ProtocolListener protocolListener() {
95-
return new ProtocolListener();
96-
}
97-
98-
@Bean
99-
public RunningExecutionTracker runningExecutionTracker() {
100-
return new RunningExecutionTracker();
101-
}
102-
103-
@Bean
104-
public RunningExecutionTrackerListener runningExecutionTrackerListener() {
105-
return new RunningExecutionTrackerListener(runningExecutionTracker());
106-
}
107-
108-
@Bean
109-
public AddListenerToJobService addListenerToJobService() {
110-
boolean addProtocolListener = batchConfig.getDefaultProtocol().isEnabled();
111-
boolean addLoggingListener = batchConfig.getLogfileSeparation().isEnabled();
112-
return new AddListenerToJobService(addProtocolListener, addLoggingListener, protocolListener(),
113-
runningExecutionTrackerListener(), loggingListener(), loggingAfterJobListener());
114-
}
115-
116-
@Override
117-
public void onApplicationEvent(ContextRefreshedEvent event) {
118-
baseConfig.jobRegistry().getJobNames().forEach(jobName -> {
119-
try {
120-
AbstractJob job = (AbstractJob) baseConfig.jobRegistry().getJob(jobName);
121-
this.addListenerToJobService().addListenerToJob(job);
122-
} catch (NoSuchJobException e) {
123-
throw new IllegalStateException(e);
124-
}
125-
});
126-
}
127-
128-
@Override
129-
public int getOrder() {
130-
return Ordered.LOWEST_PRECEDENCE;
131-
}
75+
@Autowired
76+
private BatchConfigurationProperties batchConfig;
77+
78+
@Autowired
79+
private JobRegistry jobRegistry;
80+
81+
// ################### Listeners automatically added to each job #################################
82+
83+
@Bean
84+
public LoggingListener loggingListener() {
85+
return new LoggingListener();
86+
}
87+
88+
@Bean
89+
public LoggingAfterJobListener loggingAfterJobListener() {
90+
return new LoggingAfterJobListener();
91+
}
92+
93+
@Bean
94+
public ProtocolListener protocolListener() {
95+
return new ProtocolListener();
96+
}
97+
98+
@Bean
99+
public RunningExecutionTracker runningExecutionTracker() {
100+
return new RunningExecutionTracker();
101+
}
102+
103+
@Bean
104+
public RunningExecutionTrackerListener runningExecutionTrackerListener() {
105+
return new RunningExecutionTrackerListener(runningExecutionTracker());
106+
}
107+
108+
@Bean
109+
public AddListenerToJobService addListenerToJobService() {
110+
boolean addProtocolListener = batchConfig.getDefaultProtocol().isEnabled();
111+
boolean addLoggingListener = batchConfig.getLogfileSeparation().isEnabled();
112+
return new AddListenerToJobService(addProtocolListener, addLoggingListener, protocolListener(),
113+
runningExecutionTrackerListener(), loggingListener(), loggingAfterJobListener());
114+
}
115+
116+
@Override
117+
public void onApplicationEvent(ContextRefreshedEvent event) {
118+
jobRegistry.getJobNames().forEach(jobName -> {
119+
try {
120+
AbstractJob job = (AbstractJob) jobRegistry.getJob(jobName);
121+
this.addListenerToJobService().addListenerToJob(job);
122+
} catch (NoSuchJobException e) {
123+
throw new IllegalStateException(e);
124+
}
125+
});
126+
}
127+
128+
@Override
129+
public int getOrder() {
130+
return Ordered.LOWEST_PRECEDENCE;
131+
}
132132

133133
@Bean
134134
@ConditionalOnMissingBean
135135
public JobParametersConverter jobParametersConverter() {
136-
return new DefaultJobParametersConverter();
136+
return new DefaultJobParametersConverter();
137137
}
138138

139139
}

batch-web-spring-boot-autoconfigure/src/main/java/de/codecentric/batch/configuration/Jsr352BatchConfiguration.java

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,55 @@
1515
*/
1616
package de.codecentric.batch.configuration;
1717

18+
import org.springframework.batch.core.configuration.JobRegistry;
19+
import org.springframework.batch.core.explore.JobExplorer;
1820
import org.springframework.batch.core.jsr.JsrJobParametersConverter;
21+
import org.springframework.batch.core.repository.JobRepository;
1922
import org.springframework.beans.factory.annotation.Autowired;
2023
import org.springframework.context.annotation.Bean;
2124
import org.springframework.context.annotation.Configuration;
25+
import org.springframework.core.task.TaskExecutor;
2226
import org.springframework.transaction.PlatformTransactionManager;
2327

2428
import de.codecentric.batch.jsr352.CustomJsrJobOperator;
2529

30+
import javax.sql.DataSource;
31+
2632
/**
2733
* This configuration creates the components needed for starting JSR-352 style jobs.
28-
*
34+
*
2935
* @author Tobias Flohre
3036
*/
3137
@Configuration
3238
public class Jsr352BatchConfiguration {
3339

34-
@Autowired
35-
private BaseConfiguration baseConfig;
36-
37-
@Autowired
38-
private BatchWebAutoConfiguration batchWebAutoConfiguration;
39-
40-
@Bean
41-
public CustomJsrJobOperator jsrJobOperator(PlatformTransactionManager transactionManager) throws Exception {
42-
CustomJsrJobOperator jsrJobOperator = new CustomJsrJobOperator(baseConfig.jobExplorer(),
43-
baseConfig.jobRepository(), jsrJobParametersConverter(),
44-
batchWebAutoConfiguration.addListenerToJobService(), transactionManager);
45-
jsrJobOperator.setTaskExecutor(baseConfig.taskExecutor());
46-
return jsrJobOperator;
47-
}
48-
49-
public JsrJobParametersConverter jsrJobParametersConverter() throws Exception {
50-
JsrJobParametersConverter jsrJobParametersConverter = new JsrJobParametersConverter(baseConfig.dataSource());
51-
jsrJobParametersConverter.afterPropertiesSet();
52-
return jsrJobParametersConverter;
53-
}
40+
@Autowired
41+
private JobExplorer jobExplorer;
42+
43+
@Autowired
44+
private JobRepository jobRepository;
45+
46+
@Autowired
47+
private DataSource dataSource;
48+
49+
@Autowired
50+
private TaskExecutor taskExecutor;
51+
52+
@Autowired
53+
private BatchWebAutoConfiguration batchWebAutoConfiguration;
54+
55+
@Bean
56+
public CustomJsrJobOperator jsrJobOperator(PlatformTransactionManager transactionManager) throws Exception {
57+
CustomJsrJobOperator jsrJobOperator = new CustomJsrJobOperator(jobExplorer, jobRepository, jsrJobParametersConverter(),
58+
batchWebAutoConfiguration.addListenerToJobService(), transactionManager);
59+
jsrJobOperator.setTaskExecutor(taskExecutor);
60+
return jsrJobOperator;
61+
}
62+
63+
public JsrJobParametersConverter jsrJobParametersConverter() throws Exception {
64+
JsrJobParametersConverter jsrJobParametersConverter = new JsrJobParametersConverter(dataSource);
65+
jsrJobParametersConverter.afterPropertiesSet();
66+
return jsrJobParametersConverter;
67+
}
5468

5569
}

0 commit comments

Comments
 (0)