Class JobLauncherApplicationRunner
java.lang.Object
org.springframework.boot.batch.autoconfigure.JobLauncherApplicationRunner
- All Implemented Interfaces:
Aware
,InitializingBean
,ApplicationRunner
,ApplicationEventPublisherAware
,Ordered
public class JobLauncherApplicationRunner
extends Object
implements ApplicationRunner, InitializingBean, Ordered, ApplicationEventPublisherAware
ApplicationRunner
to launch
Spring Batch jobs. If a single
job is found in the context, it will be executed by default. If multiple jobs are
found, launch a specific job by providing a jobName.- Since:
- 4.0.0
- Author:
- Dave Syer, Jean-Pierre Bergamin, Mahmoud Ben Hassine, Stephane Nicoll, Akshay Dubey
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The default order for the command line runner.Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorsConstructorDescriptionJobLauncherApplicationRunner
(org.springframework.batch.core.launch.JobOperator jobOperator) Create a newJobLauncherApplicationRunner
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
execute
(org.springframework.batch.core.job.Job job, org.springframework.batch.core.job.parameters.JobParameters jobParameters) int
getOrder()
protected void
launchJobFromProperties
(@Nullable Properties properties) void
void
run
(ApplicationArguments args) Callback used to run the bean.void
void
setJobName
(String jobName) void
setJobParametersConverter
(org.springframework.batch.core.converter.JobParametersConverter converter) void
setJobRegistry
(org.springframework.batch.core.configuration.JobRegistry jobRegistry) void
setJobs
(Collection<org.springframework.batch.core.job.Job> jobs) void
setOrder
(int order)
-
Field Details
-
DEFAULT_ORDER
public static final int DEFAULT_ORDERThe default order for the command line runner.- See Also:
-
-
Constructor Details
-
JobLauncherApplicationRunner
public JobLauncherApplicationRunner(org.springframework.batch.core.launch.JobOperator jobOperator) Create a newJobLauncherApplicationRunner
.- Parameters:
jobOperator
- to launch jobs
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceInitializingBean
-
setOrder
public void setOrder(int order) -
getOrder
-
setApplicationEventPublisher
- Specified by:
setApplicationEventPublisher
in interfaceApplicationEventPublisherAware
-
setJobRegistry
@Autowired(required=false) public void setJobRegistry(org.springframework.batch.core.configuration.JobRegistry jobRegistry) -
setJobName
-
setJobParametersConverter
@Autowired(required=false) public void setJobParametersConverter(org.springframework.batch.core.converter.JobParametersConverter converter) -
setJobs
@Autowired(required=false) public void setJobs(Collection<org.springframework.batch.core.job.Job> jobs) -
run
Description copied from interface:ApplicationRunner
Callback used to run the bean.- Specified by:
run
in interfaceApplicationRunner
- Parameters:
args
- incoming application arguments- Throws:
Exception
- on error
-
run
- Throws:
org.springframework.batch.core.job.JobExecutionException
-
launchJobFromProperties
protected void launchJobFromProperties(@Nullable Properties properties) throws org.springframework.batch.core.job.JobExecutionException - Throws:
org.springframework.batch.core.job.JobExecutionException
-
execute
protected void execute(org.springframework.batch.core.job.Job job, org.springframework.batch.core.job.parameters.JobParameters jobParameters) throws org.springframework.batch.core.repository.JobExecutionAlreadyRunningException, org.springframework.batch.core.launch.NoSuchJobException, org.springframework.batch.core.repository.JobRestartException, org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException, org.springframework.batch.core.job.parameters.JobParametersInvalidException - Throws:
org.springframework.batch.core.repository.JobExecutionAlreadyRunningException
org.springframework.batch.core.launch.NoSuchJobException
org.springframework.batch.core.repository.JobRestartException
org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException
org.springframework.batch.core.job.parameters.JobParametersInvalidException
-