Exemplo n.º 1
0
  public void afterJob(JobExecution jobExecution) {
    StringBuilder protocol = new StringBuilder();
    protocol.append("\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");
    protocol.append("Protocol for " + jobExecution.getJobInstance().getJobName() + " \n");
    protocol.append("  Started     : " + jobExecution.getStartTime() + "\n");
    protocol.append("  Finished    : " + jobExecution.getEndTime() + "\n");
    protocol.append("  Exit-Code   : " + jobExecution.getExitStatus().getExitCode() + "\n");
    protocol.append("  Exit-Descr. : " + jobExecution.getExitStatus().getExitDescription() + "\n");
    protocol.append("  Status      : " + jobExecution.getStatus() + "\n");
    protocol.append("+++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");

    protocol.append("Job-Parameter: \n");
    JobParameters jp = jobExecution.getJobParameters();
    for (Iterator<Entry<String, JobParameter>> iter = jp.getParameters().entrySet().iterator();
        iter.hasNext(); ) {
      Entry<String, JobParameter> entry = iter.next();
      protocol.append("  " + entry.getKey() + "=" + entry.getValue() + "\n");
    }
    protocol.append("+++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");

    for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
      protocol.append("\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");
      protocol.append("Step " + stepExecution.getStepName() + " \n");
      protocol.append("WriteCount: " + stepExecution.getWriteCount() + "\n");
      protocol.append("Commits: " + stepExecution.getCommitCount() + "\n");
      protocol.append("SkipCount: " + stepExecution.getSkipCount() + "\n");
      protocol.append("Rollbacks: " + stepExecution.getRollbackCount() + "\n");
      protocol.append("Filter: " + stepExecution.getFilterCount() + "\n");
      protocol.append("+++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");
    }
    LOGGER.info(protocol.toString());
  }
 @Override
 public ExitStatus afterStep(StepExecution stepExecution) {
   if (!ExitStatus.FAILED.equals(stepExecution.getExitStatus())
       && stepExecution.getSkipCount() > 0) {
     return new ExitStatus("COMPLETED WITH SKIPS");
   } else {
     return stepExecution.getExitStatus();
   }
 }