Added 'getCandidateHandlerMethods()' to HandlerMethodUtils.

This commit is contained in:
Mark Fisher
2008-11-18 18:45:47 +00:00
parent 637e124add
commit 0859124aba

View File

@@ -19,9 +19,13 @@ package org.springframework.integration.handler;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import org.springframework.aop.support.AopUtils;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Headers;
import org.springframework.util.ReflectionUtils;
/**
* Utility methods for common behavior related to Message-handling methods.
@@ -63,6 +67,22 @@ public abstract class HandlerMethodUtils {
return true;
}
public static Method[] getCandidateHandlerMethods(Object object) {
final List<Method> candidates = new ArrayList<Method>();
Class<?> clazz = AopUtils.getTargetClass(object);
if (clazz == null) {
clazz = object.getClass();
}
ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
if (HandlerMethodUtils.isValidHandlerMethod(method)) {
candidates.add(method);
}
}
});
return candidates.toArray(new Method[candidates.size()]);
}
/**
* Checks the array of Annotations for a method parameter to see if either
* the @Header or @Headers annotation is present.