From 2514346441ca281d6b68cb29370c3170cca60caa Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Wed, 7 May 2025 23:41:34 +0200 Subject: [PATCH] Deprecate JobOperator#start(String, Properties) This commit deprecates JobOperator#start(String, Properties) in favor of an overloaded method that uses domain types Job and JobParameters. --- .../batch/core/launch/JobOperator.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/JobOperator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/JobOperator.java index 2d9c91c2c..e6e570520 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/launch/JobOperator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/launch/JobOperator.java @@ -59,12 +59,36 @@ public interface JobOperator extends JobLauncher { * parameters already exists * @throws JobParametersInvalidException thrown if any of the job parameters are * invalid. + * @deprecated since 6.0 in favor of {@link #start(Job, JobParameters)}. Scheduled for + * removal in 6.2 or later. */ + @Deprecated(since = "6.0", forRemoval = true) default Long start(String jobName, Properties parameters) throws NoSuchJobException, JobInstanceAlreadyExistsException, JobParametersInvalidException { throw new UnsupportedOperationException(); } + /** + * Start a new instance of a job with the specified parameters. + * @param job the {@link Job} to start + * @param jobParameters the {@link JobParameters} to start the job with + * @return the {@link JobExecution} that was started + * @throws NoSuchJobException if the given {@link Job} is not registered + * @throws JobParametersInvalidException thrown if any of the job parameters are + * @throws JobExecutionAlreadyRunningException if the JobInstance identified by the + * properties already has an execution running. invalid. + * @throws JobRestartException if the execution would be a re-start, but a re-start is + * either not allowed or not needed. + * @throws JobInstanceAlreadyCompleteException if the job has been run before with the + * same parameters and completed successfully + * @throws IllegalArgumentException if the job or job parameters are null. + */ + default JobExecution start(Job job, JobParameters jobParameters) + throws NoSuchJobException, JobInstanceAlreadyCompleteException, JobExecutionAlreadyRunningException, + JobRestartException, JobParametersInvalidException { + return run(job, jobParameters); + } + /** * Restart a failed or stopped {@link JobExecution}. Fails with an exception if the id * provided does not exist or corresponds to a {@link JobInstance} that in normal