How to count items in a Tasket in spring-batch?
<p>I have a <code>Tasklet</code> and want to count the items processed. Then a common <code>StepExecutionListener</code> should be able to read those processed item count in <code>afterStep()</code>:</p>

<pre><code>@Bean
public Step myStep() {
    return stepBuilderFactory.get("Step2")
            .tasklet(new Tasklet() {
                @Override
                public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
                    int items = dao.deleteItems(); //how to pass these items to a StepExecutionListener?
                    return RepeatStatus.FINISHED;
                }
            })
            .build();


@Component
public class MyListener extends StepExecutionListenerSupport {
    @Override
    public ExitStatus afterStep(StepExecution stepExecution) {
        long items = stepExecution.getWriteCount();
        return super.afterStep(stepExecution);
    }
}
</code></pre>

<p>How can I get the processed items into the <code>stepExecution</code> within the tasklet?</p>