2828import org .springframework .batch .core .JobParametersInvalidException ;
2929import org .springframework .batch .core .StepExecution ;
3030import org .springframework .batch .core .UnexpectedJobExecutionException ;
31+ import org .springframework .batch .core .configuration .JobRegistry ;
3132import org .springframework .batch .core .repository .JobExecutionAlreadyRunningException ;
3233import org .springframework .batch .core .repository .JobInstanceAlreadyCompleteException ;
3334import org .springframework .batch .core .repository .JobRestartException ;
@@ -46,7 +47,10 @@ public interface JobOperator extends JobLauncher {
4647 * List the available job names that can be launched with
4748 * {@link #start(String, Properties)}.
4849 * @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.
4952 */
53+ @ Deprecated (since = "6.0" , forRemoval = true )
5054 Set <String > getJobNames ();
5155
5256 /**
@@ -104,10 +108,32 @@ default JobExecution start(Job job, JobParameters jobParameters)
104108 * @throws JobRestartException if there is a non-specific error with the restart (e.g.
105109 * corrupt or inconsistent restart data)
106110 * @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.
107113 */
114+ @ Deprecated (since = "6.0" , forRemoval = true )
108115 Long restart (long executionId ) throws JobInstanceAlreadyCompleteException , NoSuchJobExecutionException ,
109116 NoSuchJobException , JobRestartException , JobParametersInvalidException ;
110117
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+
111137 /**
112138 * Launch the next in a sequence of {@link JobInstance} determined by the
113139 * {@link JobParametersIncrementer} attached to the specified job. If the previous
@@ -132,11 +158,42 @@ Long restart(long executionId) throws JobInstanceAlreadyCompleteException, NoSuc
132158 * that is already executing.
133159 * @throws JobInstanceAlreadyCompleteException thrown if attempting to restart a
134160 * completed job.
161+ * @deprecated since 6.0 in favor of {@link #startNextInstance(Job)}. Scheduled for
162+ * removal in 6.2 or later.
135163 */
164+ @ Deprecated (since = "6.0" , forRemoval = true )
136165 Long startNextInstance (String jobName ) throws NoSuchJobException , JobParametersNotFoundException ,
137166 JobRestartException , JobExecutionAlreadyRunningException , JobInstanceAlreadyCompleteException ,
138167 UnexpectedJobExecutionException , JobParametersInvalidException ;
139168
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+
140197 /**
141198 * Send a stop signal to the {@link JobExecution} with the supplied id. The signal is
142199 * 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
148205 * supplied
149206 * @throws JobExecutionNotRunningException if the {@link JobExecution} is not running
150207 * (so cannot be stopped)
208+ * @deprecated since 6.0 in favor of {@link #stop(JobExecution)}. Scheduled for
209+ * removal in 6.2 or later.
151210 */
211+ @ Deprecated (since = "6.0" , forRemoval = true )
152212 boolean stop (long executionId ) throws NoSuchJobExecutionException , JobExecutionNotRunningException ;
153213
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+
154226 /**
155227 * Mark the {@link JobExecution} as ABANDONED. If a stop signal is ignored because the
156228 * 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
161233 * jobExecutionId.
162234 * @throws JobExecutionAlreadyRunningException if the job is running (it should be
163235 * stopped first)
236+ * @deprecated since 6.0 in favor of {@link #abandon(JobExecution)}. Scheduled for
237+ * removal in 6.2 or later.
164238 */
239+ @ Deprecated (since = "6.0" , forRemoval = true )
165240 JobExecution abandon (long jobExecutionId ) throws NoSuchJobExecutionException , JobExecutionAlreadyRunningException ;
166241
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+
167253 /**
168254 * List the {@link JobExecution JobExecutions} associated with a particular
169255 * {@link JobInstance}, in reverse order of creation (and therefore usually of
0 commit comments