org.springframework.batch.core.ProgressJobExecutionListener Maven / Gradle / Ivy
package org.springframework.batch.core;
import java.util.UUID;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class ProgressJobExecutionListener implements JobExecutionListener {
protected final Log logger = LogFactory.getLog(getClass());
private final String total = "total";
@Override
public void afterJob(JobExecution jobExecution) {
// ignore
}
@Override
public void beforeJob(JobExecution jobExecution) {
long total = jobExecution.getJobParameters().getLong(this.total, 0L);
String uuid = UUID.randomUUID().toString();
jobExecution.getExecutionContext().put(uuid, total);
// total = jobExecution.getExecutionContext().getLong(this.total, total);
// double readCount = 0D;
// for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
// readCount = readCount + stepExecution.getReadCount();
// }
// Math.round(readCount / total * 100);
}
}