Class TaskJobLauncherApplicationRunner
java.lang.Object
org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner
org.springframework.cloud.task.batch.handler.TaskJobLauncherApplicationRunner
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.InitializingBean
,org.springframework.boot.ApplicationRunner
,org.springframework.context.ApplicationEventPublisherAware
,org.springframework.core.Ordered
public class TaskJobLauncherApplicationRunner
extends org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner
ApplicationRunner
to launch
Spring Batch jobs. Runs all
jobs in the surrounding context by default and throws an exception upon the first job
that returns an BatchStatus
of FAILED if a TaskExecutor
in the
JobLauncher
is not specified. If a TaskExecutor
is specified in the
JobLauncher
then all Jobs are launched and an exception is thrown if one or
more of the jobs has an BatchStatus
of FAILED. TaskJobLauncherApplicationRunner
can also be used to launch a specific job by providing a jobName. The
TaskJobLauncherApplicationRunner takes the place of the
JobLauncherApplicationRunner
when it is in use.- Since:
- 2.3.0
- Author:
- Glenn Renfro
-
Field Summary
Fields inherited from class org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner
DEFAULT_ORDER
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionTaskJobLauncherApplicationRunner
(org.springframework.batch.core.launch.JobLauncher jobLauncher, org.springframework.batch.core.explore.JobExplorer jobExplorer, org.springframework.batch.core.repository.JobRepository jobRepository, TaskBatchProperties taskBatchProperties) Create a newTaskJobLauncherApplicationRunner
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
execute
(org.springframework.batch.core.Job job, org.springframework.batch.core.JobParameters jobParameters) void
void
setApplicationEventPublisher
(org.springframework.context.ApplicationEventPublisher publisher) Methods inherited from class org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner
afterPropertiesSet, getOrder, launchJobFromProperties, run, setJobName, setJobParametersConverter, setJobRegistry, setJobs, setOrder, validate
-
Constructor Details
-
TaskJobLauncherApplicationRunner
public TaskJobLauncherApplicationRunner(org.springframework.batch.core.launch.JobLauncher jobLauncher, org.springframework.batch.core.explore.JobExplorer jobExplorer, org.springframework.batch.core.repository.JobRepository jobRepository, TaskBatchProperties taskBatchProperties) Create a newTaskJobLauncherApplicationRunner
.- Parameters:
jobLauncher
- to launch jobsjobExplorer
- to check the job repository for previous executionsjobRepository
- to check if a job instance exists with the given parameters when running a jobtaskBatchProperties
- the properties used to configure the taskBatchProperties.
-
-
Method Details
-
setApplicationEventPublisher
public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher publisher) - Specified by:
setApplicationEventPublisher
in interfaceorg.springframework.context.ApplicationEventPublisherAware
- Overrides:
setApplicationEventPublisher
in classorg.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner
-
run
- Overrides:
run
in classorg.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner
- Throws:
org.springframework.batch.core.JobExecutionException
-
execute
protected void execute(org.springframework.batch.core.Job job, org.springframework.batch.core.JobParameters jobParameters) throws org.springframework.batch.core.repository.JobExecutionAlreadyRunningException, org.springframework.batch.core.repository.JobRestartException, org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException, org.springframework.batch.core.JobParametersInvalidException - Overrides:
execute
in classorg.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner
- Throws:
org.springframework.batch.core.repository.JobExecutionAlreadyRunningException
org.springframework.batch.core.repository.JobRestartException
org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException
org.springframework.batch.core.JobParametersInvalidException
-