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

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

Introduction

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

Prototype

public void setStepExecutionListeners(StepExecutionListener[] listeners) 

Source Link

Document

Register each of the objects as listeners.

Usage

From source file:org.springframework.batch.core.configuration.xml.StepParserStepFactoryBean.java

private void configureAbstractStep(AbstractStep ts) {
    if (name != null) {
        ts.setName(name);/*  w  w w  .  j  ava  2  s . c o  m*/
    }
    if (allowStartIfComplete != null) {
        ts.setAllowStartIfComplete(allowStartIfComplete);
    }
    if (jobRepository != null) {
        ts.setJobRepository(jobRepository);
    }
    if (startLimit != null) {
        ts.setStartLimit(startLimit);
    }
    if (listeners != null) {
        List<StepExecutionListener> newListeners = new ArrayList<StepExecutionListener>();
        for (StepListener listener : listeners) {
            if (listener instanceof StepExecutionListener) {
                newListeners.add((StepExecutionListener) listener);
            }
        }
        ts.setStepExecutionListeners(newListeners.toArray(new StepExecutionListener[0]));
    }
}

From source file:org.springframework.batch.core.step.builder.StepBuilderHelper.java

protected void enhance(Step target) {

    if (target instanceof AbstractStep) {

        AbstractStep step = (AbstractStep) target;
        step.setJobRepository(properties.getJobRepository());

        Boolean allowStartIfComplete = properties.allowStartIfComplete;
        if (allowStartIfComplete != null) {
            step.setAllowStartIfComplete(allowStartIfComplete);
        }//from  w  w  w  .  j av  a 2s  .c o  m

        step.setStartLimit(properties.startLimit);

        List<StepExecutionListener> listeners = properties.stepExecutionListeners;
        if (!listeners.isEmpty()) {
            step.setStepExecutionListeners(listeners.toArray(new StepExecutionListener[0]));
        }

    }

    if (target instanceof TaskletStep) {
        TaskletStep step = (TaskletStep) target;
        step.setTransactionManager(properties.transactionManager);
    }

}