From b4375aae21189baba6a5fba1fc5bc335c5eb7ac4 Mon Sep 17 00:00:00 2001 From: dhgarrette Date: Sat, 7 Mar 2009 07:16:06 +0000 Subject: [PATCH] BATCH-1118: Modified StepListenerFactoryBean so that listener methods specified via annotations or the metaDataMap are checked for correct signatures. This allows incorrect methods to fail eagerly. For added flexibility, methods are also allowed if they do not specify any parameters. --- .../listener/StepListenerFactoryBean.java | 56 ++++++++- .../StepListenerFactoryBeanTests.java | 106 ++++++++++++++++++ .../batch/support/MethodInvokerUtils.java | 34 ++++-- 3 files changed, 181 insertions(+), 15 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerFactoryBean.java index 243030c45..e7c51f498 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/StepListenerFactoryBean.java @@ -15,9 +15,11 @@ */ package org.springframework.batch.core.listener; -import static org.springframework.batch.support.MethodInvokerUtils.getMethodInvokerByAnnotation; import static org.springframework.batch.support.MethodInvokerUtils.getMethodInvokerForInterface; +import static org.springframework.batch.support.MethodInvokerUtils.getParamTypesString; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -31,13 +33,15 @@ import org.springframework.batch.support.MethodInvoker; import org.springframework.batch.support.MethodInvokerUtils; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; +import org.springframework.core.annotation.AnnotationUtils; import org.springframework.util.Assert; +import org.springframework.util.ReflectionUtils; /** * {@link FactoryBean} implementation that builds a {@link StepListener} based * on the various lifecycle methods or annotations that are provided. There are * three possible ways of having a method called as part of a - * {@link StepListener} lifecyle: + * {@link StepListener} lifecycle: * *