Example usage for org.springframework.batch.core.step AbstractStep registerStepExecutionListener

List of usage examples for org.springframework.batch.core.step AbstractStep registerStepExecutionListener

Introduction

In this page you can find the example usage for org.springframework.batch.core.step AbstractStep registerStepExecutionListener.

Prototype

public void registerStepExecutionListener(StepExecutionListener listener) 

Source Link

Document

Register a step listener for callbacks at the appropriate stages in a step execution.

Usage

From source file:de.codecentric.batch.listener.AddListenerToJobService.java

public void addListenerToJob(AbstractJob job) {
    if (addProtocolListener) {
        job.registerJobExecutionListener(protocolListener);
    }// ww  w.  ja v  a  2s  . c  om
    job.registerJobExecutionListener(runningExecutionTrackerListener);
    if (addLoggingListener) {
        job.registerJobExecutionListener(loggingListener);
        job.registerJobExecutionListener(loggingAfterJobListener);
        for (String stepName : job.getStepNames()) {
            AbstractStep step = (AbstractStep) job.getStep(stepName);
            step.registerStepExecutionListener(loggingListener);
        }
    }
    if (listenerProviders != null) {
        for (ListenerProvider listenerProvider : listenerProviders) {
            for (JobExecutionListener jobExecutionListener : listenerProvider.jobExecutionListeners()) {
                job.registerJobExecutionListener(jobExecutionListener);
            }
            for (StepExecutionListener stepExecutionListener : listenerProvider.stepExecutionListeners()) {
                for (String stepName : job.getStepNames()) {
                    AbstractStep step = (AbstractStep) job.getStep(stepName);
                    step.registerStepExecutionListener(stepExecutionListener);
                }
            }
        }
    }
}