Example usage for org.springframework.batch.core JobParametersBuilder JobParametersBuilder

List of usage examples for org.springframework.batch.core JobParametersBuilder JobParametersBuilder

Introduction

In this page you can find the example usage for org.springframework.batch.core JobParametersBuilder JobParametersBuilder.

Prototype

public JobParametersBuilder(JobParameters jobParameters, JobExplorer jobExplorer) 

Source Link

Document

Copy constructor.

Usage

From source file:org.springframework.cloud.task.batch.handler.TaskJobLauncherCommandLineRunner.java

protected void execute(Job job, JobParameters jobParameters)
        throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException,
        JobParametersInvalidException, JobParametersNotFoundException {
    JobParameters nextParameters = new JobParametersBuilder(jobParameters, this.jobExplorer)
            .getNextJobParameters(job).toJobParameters();
    JobExecution execution = this.jobLauncher.run(job, nextParameters);
    if (this.publisher != null) {
        this.publisher.publishEvent(new JobExecutionEvent(execution));
    }//  www  .j  av  a  2s .  com
    if (execution.getExitStatus().getExitCode().equals(ExitStatus.FAILED.getExitCode())) {
        String message = String.format(
                "Job %s failed during " + "execution for jobId %s with jobExecutionId of %s",
                execution.getJobInstance().getJobName(), execution.getJobId(), execution.getId());
        logger.error(message);
        throw new TaskException(message);
    }
}