Class JobLauncherApplicationRunner
java.lang.Object
org.springframework.boot.autoconfigure.batch.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:
- 2.3.0
- Author:
- Dave Syer, Jean-Pierre Bergamin, Mahmoud Ben Hassine, Stephane Nicoll, Akshay Dubey
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe 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.JobLauncher jobLauncher, org.springframework.batch.core.explore.JobExplorer jobExplorer, org.springframework.batch.core.repository.JobRepository jobRepository) Create a newJobLauncherApplicationRunner. -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidexecute(org.springframework.batch.core.Job job, org.springframework.batch.core.JobParameters jobParameters) intgetOrder()protected voidlaunchJobFromProperties(Properties properties) voidvoidrun(ApplicationArguments args) Callback used to run the bean.voidvoidsetJobName(String jobName) voidsetJobParametersConverter(org.springframework.batch.core.converter.JobParametersConverter converter) voidsetJobRegistry(org.springframework.batch.core.configuration.JobRegistry jobRegistry) voidsetJobs(Collection<org.springframework.batch.core.Job> jobs) voidsetOrder(int order) voidvalidate()Deprecated, for removal: This API element is subject to removal in a future version.
-
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.JobLauncher jobLauncher, org.springframework.batch.core.explore.JobExplorer jobExplorer, org.springframework.batch.core.repository.JobRepository jobRepository) Create a newJobLauncherApplicationRunner.- 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 job
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceInitializingBean
-
validate
Deprecated, for removal: This API element is subject to removal in a future version. -
setOrder
public void setOrder(int order) -
getOrder
public int getOrder() -
setApplicationEventPublisher
- Specified by:
setApplicationEventPublisherin 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
-
run
Description copied from interface:ApplicationRunnerCallback used to run the bean.- Specified by:
runin interfaceApplicationRunner- Parameters:
args- incoming application arguments- Throws:
Exception- on error
-
run
- Throws:
org.springframework.batch.core.JobExecutionException
-
launchJobFromProperties
protected void launchJobFromProperties(Properties properties) throws org.springframework.batch.core.JobExecutionException - 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 - Throws:
org.springframework.batch.core.repository.JobExecutionAlreadyRunningExceptionorg.springframework.batch.core.repository.JobRestartExceptionorg.springframework.batch.core.repository.JobInstanceAlreadyCompleteExceptionorg.springframework.batch.core.JobParametersInvalidException
-