List of usage examples for org.springframework.batch.core.listener StepListenerFactoryBean StepListenerFactoryBean
StepListenerFactoryBean
From source file:org.springframework.batch.core.step.builder.StepBuilderHelper.java
/** * Registers objects using the annotation based listener configuration. * * @param listener the object that has a method configured with listener annotation * @return this for fluent chaining/*from www.j av a 2 s .c om*/ */ public B listener(Object listener) { Set<Method> stepExecutionListenerMethods = new HashSet<Method>(); stepExecutionListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeStep.class)); stepExecutionListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterStep.class)); if (stepExecutionListenerMethods.size() > 0) { StepListenerFactoryBean factory = new StepListenerFactoryBean(); factory.setDelegate(listener); properties.addStepExecutionListener((StepExecutionListener) factory.getObject()); } @SuppressWarnings("unchecked") B result = (B) this; return result; }