Example usage for org.springframework.batch.core JobExecution getFailureExceptions

List of usage examples for org.springframework.batch.core JobExecution getFailureExceptions

Introduction

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

Prototype

public List<Throwable> getFailureExceptions() 

Source Link

Usage

From source file:bamons.process.monitoring.service.listener.EmailMonitoringNotifier.java

private String createMessageContent(JobExecution jobExecution) {
    List<Throwable> exceptions = jobExecution.getFailureExceptions();
    StringBuilder content = new StringBuilder();
    content.append("Job execution ID #");
    content.append(jobExecution.getId());
    content.append(" of job instance ID #");
    content.append(jobExecution.getJobInstance().getId());
    content.append(" failed with following exceptions : ");

    for (Throwable exception : exceptions) {
        content.append("");
        content.append(formatExceptionMessage(exception));
    }//  w w  w  .  j  a  v a 2  s. c o  m
    return content.toString();
}

From source file:org.springframework.batch.admin.domain.JobExecutionInfoResource.java

public JobExecutionInfoResource(JobExecution jobExecution, TimeZone timeZone) {

    if (timeZone != null) {
        this.timeZone = timeZone;
    } else {/*from   ww w.  j a  v a  2s.c  om*/
        this.timeZone = TimeZone.getTimeZone("UTC");
    }

    this.executionId = jobExecution.getId();
    this.jobId = jobExecution.getJobId();
    this.stepExecutionCount = jobExecution.getStepExecutions().size();
    this.jobParameters = jobExecution.getJobParameters();
    this.status = jobExecution.getStatus();
    this.exitStatus = jobExecution.getExitStatus();
    this.jobConfigurationName = jobExecution.getJobConfigurationName();
    this.failureExceptions = jobExecution.getFailureExceptions();
    Map<String, Object> executionContextEntires = new HashMap<String, Object>(
            jobExecution.getExecutionContext().size());

    for (Map.Entry<String, Object> stringObjectEntry : jobExecution.getExecutionContext().entrySet()) {
        executionContextEntires.put(stringObjectEntry.getKey(), stringObjectEntry.getValue());
    }

    this.executionContext = executionContextEntires;

    this.version = jobExecution.getVersion();

    JobInstance jobInstance = jobExecution.getJobInstance();
    if (jobInstance != null) {
        this.jobName = jobInstance.getJobName();
        BatchStatus status = jobExecution.getStatus();
        this.restartable = status.isGreaterThan(BatchStatus.STOPPING)
                && status.isLessThan(BatchStatus.ABANDONED);
        this.abandonable = status.isGreaterThan(BatchStatus.STARTED) && status != BatchStatus.ABANDONED;
        this.stoppable = status.isLessThan(BatchStatus.STOPPING) && status != BatchStatus.COMPLETED;
    } else {
        this.jobName = "?";
    }

    this.dateFormat = this.dateFormat.withZone(DateTimeZone.forTimeZone(timeZone));

    this.createDate = dateFormat.print(jobExecution.getCreateTime().getTime());
    this.lastUpdated = dateFormat.print(jobExecution.getLastUpdated().getTime());

    if (jobExecution.getStartTime() != null) {
        this.startTime = dateFormat.print(jobExecution.getStartTime().getTime());
        this.endTime = dateFormat.print(jobExecution.getEndTime().getTime());
    }
}