CAMEL-9032: Bean component - Should filter out abstract methods
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a9c704b5 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a9c704b5 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a9c704b5 Branch: refs/heads/camel-2.15.x Commit: a9c704b5ebf58fdd3b59314acd7948089ac6aa76 Parents: 4ac613e Author: Claus Ibsen <davscl...@apache.org> Authored: Wed Jul 29 10:35:01 2015 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Jul 29 11:15:48 2015 +0200 ---------------------------------------------------------------------- .../apache/camel/component/bean/BeanInfo.java | 22 +++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/a9c704b5/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java index 1b34622..d3c7214 100644 --- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java +++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java @@ -557,6 +557,12 @@ public class BeanInfo { final List<MethodInfo> localOperationsWithCustomAnnotation = new ArrayList<MethodInfo>(operationsWithCustomAnnotation); final List<MethodInfo> localOperationsWithHandlerAnnotation = new ArrayList<MethodInfo>(operationsWithHandlerAnnotation); + // remove all abstract methods + removeAllAbstractMethods(localOperationsWithBody); + removeAllAbstractMethods(localOperationsWithNoBody); + removeAllAbstractMethods(localOperationsWithCustomAnnotation); + removeAllAbstractMethods(localOperationsWithHandlerAnnotation); + if (name != null) { // filter all lists to only include methods with this name removeNonMatchingMethods(localOperationsWithHandlerAnnotation, name); @@ -831,11 +837,6 @@ public class BeanInfo { return false; } - // must not be abstract - if (Modifier.isAbstract(method.getModifiers())) { - return false; - } - // return type must not be an Exchange and it should not be a bridge method if ((method.getReturnType() != null && Exchange.class.isAssignableFrom(method.getReturnType())) || method.isBridge()) { return false; @@ -982,6 +983,17 @@ public class BeanInfo { } } + private void removeAllAbstractMethods(List<MethodInfo> methods) { + Iterator<MethodInfo> it = methods.iterator(); + while (it.hasNext()) { + MethodInfo info = it.next(); + if (Modifier.isAbstract(info.getMethod().getModifiers())) { + // we cannot invoke an abstract method + it.remove(); + } + } + } + private boolean matchMethod(Method method, String methodName) { if (methodName == null) { return true;