Package org.springframework.cloud.task.batch.handler

# 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.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

  Constructors
  Constructor
  Description
  `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 new `TaskJobLauncherApplicationRunner`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `execute(org.springframework.batch.core.Job job, org.springframework.batch.core.JobParameters jobParameters)`
  `void`
  `run(String... args)`
  `void`
  `setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher publisher)`

  ### Methods inherited from class org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner

  `getOrder, launchJobFromProperties, run, setJobNames, setJobParametersConverter, setJobRegistry, setJobs, setOrder`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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 new `TaskJobLauncherApplicationRunner`.
    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
      `taskBatchProperties` - the properties used to configure the taskBatchProperties.

- ## Method Details

  - ### setApplicationEventPublisher

    public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher publisher)
    Specified by:
      `setApplicationEventPublisher` in interface `org.springframework.context.ApplicationEventPublisherAware`
    Overrides:
      `setApplicationEventPublisher` in class `org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner`

  - ### run

    public void run(String... args) throws org.springframework.batch.core.JobExecutionException
    Overrides:
      `run` in class `org.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 class `org.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`