Skip to content

Commit 4b2586d

Browse files
committed
Replace usage of JobExplorer with JobRepository in RemoteStepExecutionAggregator
Resolves #4928
1 parent a8e138c commit 4b2586d

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2023 the original author or authors.
2+
* Copyright 2006-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@
2424
import org.springframework.batch.core.job.JobExecution;
2525
import org.springframework.batch.core.step.StepExecution;
2626
import org.springframework.batch.core.partition.StepExecutionAggregator;
27-
import org.springframework.batch.core.repository.explore.JobExplorer;
27+
import org.springframework.batch.core.repository.JobRepository;
2828
import org.springframework.beans.factory.InitializingBean;
2929
import org.springframework.util.Assert;
3030

@@ -39,7 +39,7 @@ public class RemoteStepExecutionAggregator implements StepExecutionAggregator, I
3939

4040
private StepExecutionAggregator delegate = new DefaultStepExecutionAggregator();
4141

42-
private JobExplorer jobExplorer;
42+
private JobRepository jobRepository;
4343

4444
/**
4545
* Create a new instance (useful for configuration purposes).
@@ -48,20 +48,20 @@ public RemoteStepExecutionAggregator() {
4848
}
4949

5050
/**
51-
* Create a new instance with a job explorer that can be used to refresh the data when
52-
* aggregating.
53-
* @param jobExplorer the {@link JobExplorer} to use
51+
* Create a new instance with a job repository that can be used to refresh the data
52+
* when aggregating.
53+
* @param jobRepository the {@link JobRepository} to use
5454
*/
55-
public RemoteStepExecutionAggregator(JobExplorer jobExplorer) {
55+
public RemoteStepExecutionAggregator(JobRepository jobRepository) {
5656
super();
57-
this.jobExplorer = jobExplorer;
57+
this.jobRepository = jobRepository;
5858
}
5959

6060
/**
61-
* @param jobExplorer the jobExplorer to set
61+
* @param jobRepository the jobRepository to set
6262
*/
63-
public void setJobExplorer(JobExplorer jobExplorer) {
64-
this.jobExplorer = jobExplorer;
63+
public void setJobRepository(JobRepository jobRepository) {
64+
this.jobRepository = jobRepository;
6565
}
6666

6767
/**
@@ -76,13 +76,13 @@ public void setDelegate(StepExecutionAggregator delegate) {
7676
*/
7777
@Override
7878
public void afterPropertiesSet() throws Exception {
79-
Assert.state(jobExplorer != null, "A JobExplorer must be provided");
79+
Assert.state(jobRepository != null, "A JobRepository must be provided");
8080
}
8181

8282
/**
8383
* Aggregates the input executions into the result {@link StepExecution} delegating to
8484
* the delegate aggregator once the input has been refreshed from the
85-
* {@link JobExplorer}.
85+
* {@link JobRepository}.
8686
*
8787
* @see StepExecutionAggregator #aggregate(StepExecution, Collection)
8888
*/
@@ -97,7 +97,7 @@ public void aggregate(StepExecution result, Collection<StepExecution> executions
9797
Assert.state(id != null, "StepExecution has null id. It must be saved first: " + stepExecution);
9898
return id;
9999
}).collect(Collectors.toSet());
100-
JobExecution jobExecution = jobExplorer.getJobExecution(result.getJobExecutionId());
100+
JobExecution jobExecution = jobRepository.getJobExecution(result.getJobExecutionId());
101101
Assert.state(jobExecution != null,
102102
"Could not load JobExecution from JobRepository for id " + result.getJobExecutionId());
103103
List<StepExecution> updates = jobExecution.getStepExecutions()

spring-batch-core/src/test/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregatorTests.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2022 the original author or authors.
2+
* Copyright 2011-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@
2121
import org.springframework.batch.core.job.JobExecution;
2222
import org.springframework.batch.core.job.parameters.JobParameters;
2323
import org.springframework.batch.core.step.StepExecution;
24-
import org.springframework.batch.core.repository.explore.support.JobExplorerFactoryBean;
2524
import org.springframework.batch.core.repository.JobRepository;
2625
import org.springframework.batch.core.repository.support.JdbcJobRepositoryFactoryBean;
2726
import org.springframework.jdbc.support.JdbcTransactionManager;
@@ -48,7 +47,6 @@ class RemoteStepExecutionAggregatorTests {
4847

4948
private StepExecution stepExecution2;
5049

51-
@SuppressWarnings("removal")
5250
@BeforeEach
5351
void init() throws Exception {
5452
EmbeddedDatabase embeddedDatabase = new EmbeddedDatabaseBuilder()
@@ -61,11 +59,7 @@ void init() throws Exception {
6159
factory.setTransactionManager(transactionManager);
6260
factory.afterPropertiesSet();
6361
JobRepository jobRepository = factory.getObject();
64-
JobExplorerFactoryBean explorerFactoryBean = new JobExplorerFactoryBean();
65-
explorerFactoryBean.setDataSource(embeddedDatabase);
66-
explorerFactoryBean.setTransactionManager(transactionManager);
67-
explorerFactoryBean.afterPropertiesSet();
68-
aggregator.setJobExplorer(explorerFactoryBean.getObject());
62+
aggregator.setJobRepository(jobRepository);
6963
jobExecution = jobRepository.createJobExecution("job", new JobParameters());
7064
result = jobExecution.createStepExecution("aggregate");
7165
stepExecution1 = jobExecution.createStepExecution("foo:1");

0 commit comments

Comments
 (0)