To solve this problem, here is how I did it:
In ItemProcessor, I added an attribute and method to access the ExecutionContext from the processing method,
private ExecutionContext executionContext; @BeforeStep public void beforeStep(StepExecution stepExecution) { this.executionContext = stepExecution.getExecutionContext(); }
... and then in the process () method, when I find one of the lines that I want to write, I can do this,
this.executionContext.putInt( "i_ThoseRows", this.executionContext.getInt( "i_ThoseRows", 0 ) + 1 );
Finally, I add another method for ItemProcessor to print the result at the end of the step,
@AfterStep public void afterStep(StepExecution stepExecution) { System.out.println( "Number of 'Those rows': " + this.executionContext.getInt( "i_ThoseRows", 0 ) ); }
Hope this helps someone
source share