Class JobLauncherApplicationRunner

java.lang.Object
org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner
All Implemented Interfaces:
Aware, ApplicationRunner, ApplicationEventPublisherAware, Ordered

public class JobLauncherApplicationRunner extends Object implements ApplicationRunner, Ordered, ApplicationEventPublisherAware
ApplicationRunner to launch Spring Batch jobs. Runs all jobs in the surrounding context by default. Can also be used to launch a specific job by providing a jobName
Since:
2.3.0
Author:
Dave Syer, Jean-Pierre Bergamin, Mahmoud Ben Hassine, Stephane Nicoll
  • Field Details

    • DEFAULT_ORDER

      public static final int DEFAULT_ORDER
      The 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)
      Parameters:
      jobLauncher - to launch jobs
      jobExplorer - to check the job repository for previous executions
      jobRepository - to check if a job instance exists with the given parameters when running a job
  • Method Details

    • validate

      @PostConstruct public void validate()
    • setOrder

      public void setOrder(int order)
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface Ordered
    • setApplicationEventPublisher

      public void setApplicationEventPublisher(ApplicationEventPublisher publisher)
      Specified by:
      setApplicationEventPublisher in interface ApplicationEventPublisherAware
    • setJobRegistry

      @Autowired(required=false) public void setJobRegistry(org.springframework.batch.core.configuration.JobRegistry jobRegistry)
    • setJobName

      public void setJobName(String jobName)
    • 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> jobs)
    • run

      public void run(ApplicationArguments args) throws Exception
      Description copied from interface: ApplicationRunner
      Callback used to run the bean.
      Specified by:
      run in interface ApplicationRunner
      Parameters:
      args - incoming application arguments
      Throws:
      Exception - on error
    • run

      public void run(String... args) throws org.springframework.batch.core.JobExecutionException
      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.JobExecutionAlreadyRunningException
      org.springframework.batch.core.repository.JobRestartException
      org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException
      org.springframework.batch.core.JobParametersInvalidException