In Spring Batch I have a custom ItemProcessor. I want to pass information from the afterStep to the process method. Here's the code
@Component
public class Clf010Processor implements ItemProcessor<Clf010Item, Clf010Item> {
private StepExecution stepExecution;
BatchProgram batch = new BatchProgram();
@AfterStep
public void afterStep(StepExecution stepExecution) {
ExecutionContext je = stepExecution.getJobExecution().getExecutionContext();
// Pass the counts up to the execution context.
je.putLong("writeCount", stepExecution.getWriteCount());
je.putLong("clfCount", stepExecution.getWriteCount());
}
@BeforeStep
public void beforeStep(StepExecution stepExecution) {
this.stepExecution = stepExecution;
}
@Override
public Clf010Item process(Clf010Item item) throws Exception {
batch.print("writeCount = ", stepExecution.getWriteCount());
return item;
}
}
I want to access writeCount and clfCount from after step in process. Like:
@Override
public Clf010Item process(Clf010Item item) throws Exception {
batch.print("writecount = ", stepExecution.getWriteCount());
return item;
}
Is this possible?