Skip to content

Commit afdd842

Browse files
committed
Improve JobOperator by reducing its scope to job operations only
Resolves #4833
1 parent fc4a665 commit afdd842

File tree

2 files changed

+39
-11
lines changed

2 files changed

+39
-11
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/launch/JobOperator.java

+29-5
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@
3434
import org.springframework.lang.Nullable;
3535

3636
/**
37-
* Low level interface for inspecting and controlling jobs with access only to primitive
38-
* and collection types. Suitable for a command-line client (e.g. that launches a new
39-
* process for each operation), or a remote launcher like a JMX console.
37+
* High level interface for operating batch jobs.
4038
*
4139
* @author Dave Syer
4240
* @author Mahmoud Ben Hassine
@@ -53,7 +51,11 @@ public interface JobOperator extends JobLauncher {
5351
* this instance
5452
* @throws NoSuchJobInstanceException if the {@link JobInstance} associated with the
5553
* {@code instanceId} cannot be found.
54+
* @deprecated Since 6.0 in favor of
55+
* {@link org.springframework.batch.core.repository.JobRepository#getJobExecutions(JobInstance)}.
56+
* Scheduled for removal in 6.2 or later.
5657
*/
58+
@Deprecated(since = "6.0", forRemoval = true)
5759
List<Long> getExecutions(long instanceId) throws NoSuchJobInstanceException;
5860

5961
/**
@@ -65,17 +67,23 @@ public interface JobOperator extends JobLauncher {
6567
* @return the id values of the {@link JobInstance JobInstances}
6668
* @throws NoSuchJobException is thrown if no {@link JobInstance}s for the jobName
6769
* exist.
70+
* @deprecated Since 6.0 in favor of
71+
* {@link org.springframework.batch.core.repository.JobRepository#getJobInstances(String, int, int)}.
72+
* Scheduled for removal in 6.2 or later.
6873
*/
74+
@Deprecated(since = "6.0", forRemoval = true)
6975
List<Long> getJobInstances(String jobName, int start, int count) throws NoSuchJobException;
7076

7177
/**
7278
* @param jobName {@link String} name of the job.
7379
* @param jobParameters {@link JobParameters} parameters for the job instance.
7480
* @return the {@link JobInstance} with the given name and parameters, or
7581
* {@code null}.
76-
*
77-
* @since 5.0
82+
* @deprecated Since 6.0 in favor of
83+
* {@link org.springframework.batch.core.repository.JobRepository#getJobInstance(String, JobParameters)}.
84+
* Scheduled for removal in 6.2 or later.
7885
*/
86+
@Deprecated(since = "6.0", forRemoval = true)
7987
@Nullable
8088
default JobInstance getJobInstance(String jobName, JobParameters jobParameters) {
8189
throw new UnsupportedOperationException();
@@ -88,7 +96,11 @@ default JobInstance getJobInstance(String jobName, JobParameters jobParameters)
8896
* @return the id values of the running {@link JobExecution} instances
8997
* @throws NoSuchJobException if there are no {@link JobExecution JobExecutions} with
9098
* that job name
99+
* @deprecated Since 6.0 in favor of
100+
* {@link org.springframework.batch.core.repository.JobRepository#findRunningJobExecutions(String)}.
101+
* Scheduled for removal in 6.2 or later.
91102
*/
103+
@Deprecated(since = "6.0", forRemoval = true)
92104
Set<Long> getRunningExecutions(String jobName) throws NoSuchJobException;
93105

94106
/**
@@ -98,7 +110,11 @@ default JobInstance getJobInstance(String jobName, JobParameters jobParameters)
98110
* @return the job parameters that were used to launch the associated instance
99111
* @throws NoSuchJobExecutionException if the id was not associated with any
100112
* {@link JobExecution}
113+
* @deprecated Since 6.0 in favor of
114+
* {@link org.springframework.batch.core.repository.JobRepository#getJobExecution(Long).getJobParameters()}.
115+
* Scheduled for removal in 6.2 or later.
101116
*/
117+
@Deprecated(since = "6.0", forRemoval = true)
102118
String getParameters(long executionId) throws NoSuchJobExecutionException;
103119

104120
/**
@@ -186,7 +202,11 @@ Long startNextInstance(String jobName) throws NoSuchJobException, JobParametersN
186202
* @return a String summarising the state of the job execution
187203
* @throws NoSuchJobExecutionException if there is no {@link JobExecution} with the
188204
* supplied id
205+
* @deprecated Since 6.0 in favor of
206+
* {@link org.springframework.batch.core.repository.JobRepository#getJobExecution(Long).toString()}.
207+
* Scheduled for removal in 6.2 or later.
189208
*/
209+
@Deprecated(since = "6.0", forRemoval = true)
190210
String getSummary(long executionId) throws NoSuchJobExecutionException;
191211

192212
/**
@@ -196,7 +216,11 @@ Long startNextInstance(String jobName) throws NoSuchJobException, JobParametersN
196216
* @return a map of step execution id to String summarising the state of the execution
197217
* @throws NoSuchJobExecutionException if there is no {@link JobExecution} with the
198218
* supplied id
219+
* @deprecated Since 6.0 in favor of
220+
* {@link org.springframework.batch.core.repository.JobRepository#getJobExecution(Long).getStepExecutions()}.
221+
* Scheduled for removal in 6.2 or later.
199222
*/
223+
@Deprecated(since = "6.0", forRemoval = true)
200224
Map<Long, String> getStepExecutionSummaries(long executionId) throws NoSuchJobExecutionException;
201225

202226
/**

spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java

+10-6
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@
4242
import org.springframework.batch.core.configuration.ListableJobLocator;
4343
import org.springframework.batch.core.converter.DefaultJobParametersConverter;
4444
import org.springframework.batch.core.converter.JobParametersConverter;
45-
import org.springframework.batch.core.repository.explore.JobExplorer;
4645
import org.springframework.batch.core.launch.JobExecutionNotRunningException;
4746
import org.springframework.batch.core.launch.JobInstanceAlreadyExistsException;
48-
import org.springframework.batch.core.launch.JobLauncher;
4947
import org.springframework.batch.core.launch.JobOperator;
5048
import org.springframework.batch.core.launch.NoSuchJobException;
5149
import org.springframework.batch.core.launch.NoSuchJobExecutionException;
@@ -66,12 +64,10 @@
6664
import org.springframework.util.Assert;
6765

6866
/**
69-
* Simple implementation of the JobOperator interface. Due to the amount of functionality
70-
* the implementation is combining, the following dependencies are required:
67+
* Simple implementation of the {@link JobOperator} interface. the following dependencies
68+
* are required:
7169
*
7270
* <ul>
73-
* <li>{@link JobLauncher}
74-
* <li>{@link JobExplorer}
7571
* <li>{@link JobRepository}
7672
* <li>{@link JobRegistry}
7773
* </ul>
@@ -112,6 +108,7 @@ public void afterPropertiesSet() throws Exception {
112108
* Public setter for the {@link JobParametersConverter}.
113109
* @param jobParametersConverter the {@link JobParametersConverter} to set
114110
*/
111+
@Deprecated(since = "6.0", forRemoval = true)
115112
public void setJobParametersConverter(JobParametersConverter jobParametersConverter) {
116113
this.jobParametersConverter = jobParametersConverter;
117114
}
@@ -125,6 +122,7 @@ public void setJobRegistry(ListableJobLocator jobRegistry) {
125122
}
126123

127124
@Override
125+
@Deprecated(since = "6.0", forRemoval = true)
128126
public List<Long> getExecutions(long instanceId) throws NoSuchJobInstanceException {
129127
JobInstance jobInstance = jobRepository.getJobInstance(instanceId);
130128
if (jobInstance == null) {
@@ -143,6 +141,7 @@ public Set<String> getJobNames() {
143141
}
144142

145143
@Override
144+
@Deprecated(since = "6.0", forRemoval = true)
146145
public List<Long> getJobInstances(String jobName, int start, int count) throws NoSuchJobException {
147146
List<Long> list = new ArrayList<>();
148147
List<JobInstance> jobInstances = jobRepository.getJobInstances(jobName, start, count);
@@ -157,11 +156,13 @@ public List<Long> getJobInstances(String jobName, int start, int count) throws N
157156

158157
@Override
159158
@Nullable
159+
@Deprecated(since = "6.0", forRemoval = true)
160160
public JobInstance getJobInstance(String jobName, JobParameters jobParameters) {
161161
return this.jobRepository.getJobInstance(jobName, jobParameters);
162162
}
163163

164164
@Override
165+
@Deprecated(since = "6.0", forRemoval = true)
165166
public String getParameters(long executionId) throws NoSuchJobExecutionException {
166167
JobExecution jobExecution = findExecutionById(executionId);
167168

@@ -171,6 +172,7 @@ public String getParameters(long executionId) throws NoSuchJobExecutionException
171172
}
172173

173174
@Override
175+
@Deprecated(since = "6.0", forRemoval = true)
174176
public Set<Long> getRunningExecutions(String jobName) throws NoSuchJobException {
175177
Set<Long> set = new LinkedHashSet<>();
176178
for (JobExecution jobExecution : jobRepository.findRunningJobExecutions(jobName)) {
@@ -183,6 +185,7 @@ public Set<Long> getRunningExecutions(String jobName) throws NoSuchJobException
183185
}
184186

185187
@Override
188+
@Deprecated(since = "6.0", forRemoval = true)
186189
public Map<Long, String> getStepExecutionSummaries(long executionId) throws NoSuchJobExecutionException {
187190
JobExecution jobExecution = findExecutionById(executionId);
188191

@@ -194,6 +197,7 @@ public Map<Long, String> getStepExecutionSummaries(long executionId) throws NoSu
194197
}
195198

196199
@Override
200+
@Deprecated(since = "6.0", forRemoval = true)
197201
public String getSummary(long executionId) throws NoSuchJobExecutionException {
198202
JobExecution jobExecution = findExecutionById(executionId);
199203
return jobExecution.toString();

0 commit comments

Comments
 (0)