28
28
import org .springframework .batch .core .JobParametersInvalidException ;
29
29
import org .springframework .batch .core .StepExecution ;
30
30
import org .springframework .batch .core .UnexpectedJobExecutionException ;
31
+ import org .springframework .batch .core .configuration .JobRegistry ;
31
32
import org .springframework .batch .core .repository .JobExecutionAlreadyRunningException ;
32
33
import org .springframework .batch .core .repository .JobInstanceAlreadyCompleteException ;
33
34
import org .springframework .batch .core .repository .JobRestartException ;
@@ -46,7 +47,10 @@ public interface JobOperator extends JobLauncher {
46
47
* List the available job names that can be launched with
47
48
* {@link #start(String, Properties)}.
48
49
* @return a set of job names
50
+ * @deprecated since 6.0 in favor of {@link JobRegistry#getJobNames()}. Scheduled for
51
+ * removal in 6.2 or later.
49
52
*/
53
+ @ Deprecated (since = "6.0" , forRemoval = true )
50
54
Set <String > getJobNames ();
51
55
52
56
/**
@@ -104,10 +108,32 @@ default JobExecution start(Job job, JobParameters jobParameters)
104
108
* @throws JobRestartException if there is a non-specific error with the restart (e.g.
105
109
* corrupt or inconsistent restart data)
106
110
* @throws JobParametersInvalidException if the parameters are not valid for this job
111
+ * @deprecated since 6.0 in favor of {@link #restart(JobExecution)}. Scheduled for
112
+ * removal in 6.2 or later.
107
113
*/
114
+ @ Deprecated (since = "6.0" , forRemoval = true )
108
115
Long restart (long executionId ) throws JobInstanceAlreadyCompleteException , NoSuchJobExecutionException ,
109
116
NoSuchJobException , JobRestartException , JobParametersInvalidException ;
110
117
118
+ /**
119
+ * Restart a failed or stopped {@link JobExecution}. Fails with an exception if the
120
+ * execution provided does not exist or corresponds to a {@link JobInstance} that in
121
+ * normal circumstances already completed successfully.
122
+ * @param jobExecution the failed or stopped {@link JobExecution} to restart
123
+ * @return the {@link JobExecution} that was started
124
+ * @throws JobInstanceAlreadyCompleteException if the job was already successfully
125
+ * completed
126
+ * @throws NoSuchJobExecutionException if the id was not associated with any
127
+ * {@link JobExecution}
128
+ * @throws NoSuchJobException if the {@link JobExecution} was found, but its
129
+ * corresponding {@link Job} is no longer available for launching
130
+ * @throws JobRestartException if there is a non-specific error with the restart (e.g.
131
+ * corrupt or inconsistent restart data)
132
+ * @throws JobParametersInvalidException if the parameters are not valid for this job
133
+ */
134
+ JobExecution restart (JobExecution jobExecution ) throws JobInstanceAlreadyCompleteException ,
135
+ NoSuchJobExecutionException , NoSuchJobException , JobRestartException , JobParametersInvalidException ;
136
+
111
137
/**
112
138
* Launch the next in a sequence of {@link JobInstance} determined by the
113
139
* {@link JobParametersIncrementer} attached to the specified job. If the previous
@@ -132,11 +158,42 @@ Long restart(long executionId) throws JobInstanceAlreadyCompleteException, NoSuc
132
158
* that is already executing.
133
159
* @throws JobInstanceAlreadyCompleteException thrown if attempting to restart a
134
160
* completed job.
161
+ * @deprecated since 6.0 in favor of {@link #startNextInstance(Job)}. Scheduled for
162
+ * removal in 6.2 or later.
135
163
*/
164
+ @ Deprecated (since = "6.0" , forRemoval = true )
136
165
Long startNextInstance (String jobName ) throws NoSuchJobException , JobParametersNotFoundException ,
137
166
JobRestartException , JobExecutionAlreadyRunningException , JobInstanceAlreadyCompleteException ,
138
167
UnexpectedJobExecutionException , JobParametersInvalidException ;
139
168
169
+ /**
170
+ * Launch the next in a sequence of {@link JobInstance} determined by the
171
+ * {@link JobParametersIncrementer} attached to the specified job. If the previous
172
+ * instance is still in a failed state, this method should still create a new instance
173
+ * and run it with different parameters (as long as the
174
+ * {@link JobParametersIncrementer} is working).<br>
175
+ * <br>
176
+ *
177
+ * The last three exception described below should be extremely unlikely, but cannot
178
+ * be ruled out entirely. It points to some other thread or process trying to use this
179
+ * method (or a similar one) at the same time.
180
+ * @param job the job to launch
181
+ * @return the {@link JobExecution} created when the job is launched
182
+ * @throws NoSuchJobException if there is no such job definition available
183
+ * @throws JobParametersNotFoundException if the parameters cannot be found
184
+ * @throws JobParametersInvalidException thrown if some of the job parameters are
185
+ * invalid.
186
+ * @throws UnexpectedJobExecutionException if an unexpected condition arises
187
+ * @throws JobRestartException thrown if a job is restarted illegally.
188
+ * @throws JobExecutionAlreadyRunningException thrown if attempting to restart a job
189
+ * that is already executing.
190
+ * @throws JobInstanceAlreadyCompleteException thrown if attempting to restart a
191
+ * completed job.
192
+ */
193
+ JobExecution startNextInstance (Job job ) throws NoSuchJobException , JobParametersNotFoundException ,
194
+ JobRestartException , JobExecutionAlreadyRunningException , JobInstanceAlreadyCompleteException ,
195
+ UnexpectedJobExecutionException , JobParametersInvalidException ;
196
+
140
197
/**
141
198
* Send a stop signal to the {@link JobExecution} with the supplied id. The signal is
142
199
* successfully sent if this method returns true, but that doesn't mean that the job
@@ -148,9 +205,24 @@ Long startNextInstance(String jobName) throws NoSuchJobException, JobParametersN
148
205
* supplied
149
206
* @throws JobExecutionNotRunningException if the {@link JobExecution} is not running
150
207
* (so cannot be stopped)
208
+ * @deprecated since 6.0 in favor of {@link #stop(JobExecution)}. Scheduled for
209
+ * removal in 6.2 or later.
151
210
*/
211
+ @ Deprecated (since = "6.0" , forRemoval = true )
152
212
boolean stop (long executionId ) throws NoSuchJobExecutionException , JobExecutionNotRunningException ;
153
213
214
+ /**
215
+ * Send a stop signal to the supplied {@link JobExecution}. The signal is successfully
216
+ * sent if this method returns true, but that doesn't mean that the job has stopped.
217
+ * The only way to be sure of that is to poll the job execution status.
218
+ * @param jobExecution the running {@link JobExecution}
219
+ * @return true if the message was successfully sent (does not guarantee that the job
220
+ * has stopped)
221
+ * @throws JobExecutionNotRunningException if the supplied {@link JobExecution} is not
222
+ * running (so cannot be stopped)
223
+ */
224
+ boolean stop (JobExecution jobExecution ) throws JobExecutionNotRunningException ;
225
+
154
226
/**
155
227
* Mark the {@link JobExecution} as ABANDONED. If a stop signal is ignored because the
156
228
* process died this is the best way to mark a job as finished with (as opposed to
@@ -161,9 +233,23 @@ Long startNextInstance(String jobName) throws NoSuchJobException, JobParametersN
161
233
* jobExecutionId.
162
234
* @throws JobExecutionAlreadyRunningException if the job is running (it should be
163
235
* stopped first)
236
+ * @deprecated since 6.0 in favor of {@link #abandon(JobExecution)}. Scheduled for
237
+ * removal in 6.2 or later.
164
238
*/
239
+ @ Deprecated (since = "6.0" , forRemoval = true )
165
240
JobExecution abandon (long jobExecutionId ) throws NoSuchJobExecutionException , JobExecutionAlreadyRunningException ;
166
241
242
+ /**
243
+ * Mark the {@link JobExecution} as ABANDONED. If a stop signal is ignored because the
244
+ * process died this is the best way to mark a job as finished with (as opposed to
245
+ * STOPPED). An abandoned job execution cannot be restarted by the framework.
246
+ * @param jobExecution the job execution to abort
247
+ * @return the {@link JobExecution} that was aborted
248
+ * @throws JobExecutionAlreadyRunningException if the job execution is running (it
249
+ * should be stopped first)
250
+ */
251
+ JobExecution abandon (JobExecution jobExecution ) throws JobExecutionAlreadyRunningException ;
252
+
167
253
/**
168
254
* List the {@link JobExecution JobExecutions} associated with a particular
169
255
* {@link JobInstance}, in reverse order of creation (and therefore usually of
0 commit comments