You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/07/29 11:07:02 UTC

[3/3] camel git commit: CAMEL-9032: Bean component - Should filter out abstract methods

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/108d94f7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/108d94f7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/108d94f7

Branch: refs/heads/master
Commit: 108d94f729d16f00fc29532eff8e1ca17fb63ec9
Parents: 5461749
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Jul 29 10:35:01 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Jul 29 10:35:01 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/108d94f7/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;