INT-797 Any method originally defined on Object is now excluded from the candidates for Message-handling.

This commit is contained in:
Mark Fisher
2009-09-22 19:07:28 +00:00
parent 9759e0e7dc
commit 5f32e5a1aa
2 changed files with 119 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ import java.util.Map;
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.
@@ -42,7 +43,7 @@ abstract class HandlerMethodUtils {
* object. Others must be annotated for accepting Message header values.
*/
public static boolean isValidHandlerMethod(Method method) {
if (method.getDeclaringClass().equals(Object.class)) {
if (isMethodDefinedOnObjectClass(method)) {
return false;
}
if (!Modifier.isPublic(method.getModifiers())) {
@@ -96,4 +97,20 @@ abstract class HandlerMethodUtils {
return false;
}
private static boolean isMethodDefinedOnObjectClass(Method method) {
if (method == null) {
return false;
}
if (method.getDeclaringClass().equals(Object.class)) {
return true;
}
if (ReflectionUtils.isEqualsMethod(method) ||
ReflectionUtils.isHashCodeMethod(method) ||
ReflectionUtils.isToStringMethod(method) ||
AopUtils.isFinalizeMethod(method)) {
return true;
}
return (method.getName().equals("clone") && method.getParameterTypes().length == 0);
}
}