Deprecate JobOperator#start(String, String)
This method accepts job parameters as a string, which can cause parsing issues. Resolves #4304
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
* Copyright 2006-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@ package org.springframework.batch.core.launch;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.batch.core.Job;
|
||||
@@ -111,10 +112,29 @@ public interface JobOperator {
|
||||
* parameters already exists
|
||||
* @throws JobParametersInvalidException thrown if any of the job parameters are
|
||||
* invalid.
|
||||
* @deprecated use {@link #start(String, Properties)} instead. Will be removed in
|
||||
* v5.2.
|
||||
*/
|
||||
@Deprecated(since = "5.0.1", forRemoval = true)
|
||||
Long start(String jobName, String parameters)
|
||||
throws NoSuchJobException, JobInstanceAlreadyExistsException, JobParametersInvalidException;
|
||||
|
||||
/**
|
||||
* Start a new instance of a job with the parameters specified.
|
||||
* @param jobName the name of the {@link Job} to launch
|
||||
* @param parameters the parameters to launch it with
|
||||
* @return the id of the {@link JobExecution} that is launched
|
||||
* @throws NoSuchJobException if there is no {@link Job} with the specified name
|
||||
* @throws JobInstanceAlreadyExistsException if a job instance with this name and
|
||||
* parameters already exists
|
||||
* @throws JobParametersInvalidException thrown if any of the job parameters are
|
||||
* invalid.
|
||||
*/
|
||||
default Long start(String jobName, Properties parameters)
|
||||
throws NoSuchJobException, JobInstanceAlreadyExistsException, JobParametersInvalidException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -199,7 +219,7 @@ public interface JobOperator {
|
||||
|
||||
/**
|
||||
* List the available job names that can be launched with
|
||||
* {@link #start(String, String)}.
|
||||
* {@link #start(String, Properties)}.
|
||||
* @return a set of job names
|
||||
*/
|
||||
Set<String> getJobNames();
|
||||
|
||||
@@ -309,14 +309,27 @@ public class SimpleJobOperator implements JobOperator, InitializingBean {
|
||||
* java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@Deprecated(since = "5.0.1", forRemoval = true)
|
||||
public Long start(String jobName, String parameters)
|
||||
throws NoSuchJobException, JobInstanceAlreadyExistsException, JobParametersInvalidException {
|
||||
Properties properties = PropertiesConverter.stringToProperties(parameters);
|
||||
return start(jobName, properties);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.batch.core.launch.JobOperator#start(java.lang.String,
|
||||
* java.util.Properties)
|
||||
*/
|
||||
@Override
|
||||
public Long start(String jobName, Properties parameters)
|
||||
throws NoSuchJobException, JobInstanceAlreadyExistsException, JobParametersInvalidException {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Checking status of job with name=" + jobName);
|
||||
}
|
||||
|
||||
Properties properties = PropertiesConverter.stringToProperties(parameters);
|
||||
JobParameters jobParameters = jobParametersConverter.getJobParameters(properties);
|
||||
JobParameters jobParameters = jobParametersConverter.getJobParameters(parameters);
|
||||
|
||||
if (jobRepository.isJobInstanceExists(jobName, jobParameters)) {
|
||||
throw new JobInstanceAlreadyExistsException(
|
||||
|
||||
Reference in New Issue
Block a user