|
|
|
@ -31,13 +31,12 @@ import org.springframework.batch.core.converter.JobParametersConverter; |
|
|
|
import org.springframework.batch.core.job.Job; |
|
|
|
import org.springframework.batch.core.job.Job; |
|
|
|
import org.springframework.batch.core.job.JobExecution; |
|
|
|
import org.springframework.batch.core.job.JobExecution; |
|
|
|
import org.springframework.batch.core.job.JobExecutionException; |
|
|
|
import org.springframework.batch.core.job.JobExecutionException; |
|
|
|
|
|
|
|
import org.springframework.batch.core.job.parameters.InvalidJobParametersException; |
|
|
|
import org.springframework.batch.core.job.parameters.JobParameters; |
|
|
|
import org.springframework.batch.core.job.parameters.JobParameters; |
|
|
|
import org.springframework.batch.core.job.parameters.JobParametersInvalidException; |
|
|
|
import org.springframework.batch.core.launch.JobExecutionAlreadyRunningException; |
|
|
|
|
|
|
|
import org.springframework.batch.core.launch.JobInstanceAlreadyCompleteException; |
|
|
|
import org.springframework.batch.core.launch.JobOperator; |
|
|
|
import org.springframework.batch.core.launch.JobOperator; |
|
|
|
import org.springframework.batch.core.launch.NoSuchJobException; |
|
|
|
import org.springframework.batch.core.launch.JobRestartException; |
|
|
|
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; |
|
|
|
|
|
|
|
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; |
|
|
|
|
|
|
|
import org.springframework.batch.core.repository.JobRestartException; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.InitializingBean; |
|
|
|
import org.springframework.beans.factory.InitializingBean; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.boot.ApplicationArguments; |
|
|
|
import org.springframework.boot.ApplicationArguments; |
|
|
|
@ -146,10 +145,11 @@ public class JobLauncherApplicationRunner |
|
|
|
|
|
|
|
|
|
|
|
public void run(String... args) throws JobExecutionException { |
|
|
|
public void run(String... args) throws JobExecutionException { |
|
|
|
logger.info("Running default command line with: " + Arrays.asList(args)); |
|
|
|
logger.info("Running default command line with: " + Arrays.asList(args)); |
|
|
|
launchJobFromProperties(StringUtils.splitArrayElementsIntoProperties(args, "=")); |
|
|
|
Properties properties = StringUtils.splitArrayElementsIntoProperties(args, "="); |
|
|
|
|
|
|
|
launchJobFromProperties((properties != null) ? properties : new Properties()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void launchJobFromProperties(@Nullable Properties properties) throws JobExecutionException { |
|
|
|
protected void launchJobFromProperties(Properties properties) throws JobExecutionException { |
|
|
|
JobParameters jobParameters = this.converter.getJobParameters(properties); |
|
|
|
JobParameters jobParameters = this.converter.getJobParameters(properties); |
|
|
|
executeLocalJobs(jobParameters); |
|
|
|
executeLocalJobs(jobParameters); |
|
|
|
executeRegisteredJobs(jobParameters); |
|
|
|
executeRegisteredJobs(jobParameters); |
|
|
|
@ -179,14 +179,15 @@ public class JobLauncherApplicationRunner |
|
|
|
if (this.jobRegistry != null && StringUtils.hasText(this.jobName)) { |
|
|
|
if (this.jobRegistry != null && StringUtils.hasText(this.jobName)) { |
|
|
|
if (!isLocalJob(this.jobName)) { |
|
|
|
if (!isLocalJob(this.jobName)) { |
|
|
|
Job job = this.jobRegistry.getJob(this.jobName); |
|
|
|
Job job = this.jobRegistry.getJob(this.jobName); |
|
|
|
execute(job, jobParameters); |
|
|
|
if (job != null) { |
|
|
|
|
|
|
|
execute(job, jobParameters); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void execute(Job job, JobParameters jobParameters) |
|
|
|
protected void execute(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, |
|
|
|
throws JobExecutionAlreadyRunningException, NoSuchJobException, JobRestartException, |
|
|
|
JobRestartException, JobInstanceAlreadyCompleteException, InvalidJobParametersException { |
|
|
|
JobInstanceAlreadyCompleteException, JobParametersInvalidException { |
|
|
|
|
|
|
|
JobExecution execution = this.jobOperator.start(job, jobParameters); |
|
|
|
JobExecution execution = this.jobOperator.start(job, jobParameters); |
|
|
|
if (this.publisher != null) { |
|
|
|
if (this.publisher != null) { |
|
|
|
this.publisher.publishEvent(new JobExecutionEvent(execution)); |
|
|
|
this.publisher.publishEvent(new JobExecutionEvent(execution)); |
|
|
|
|