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 2014/12/10 17:32:13 UTC

[03/15] camel git commit: CAMEL-8137: Bean component should detect override methods that are assignable by type, so duplicate methods is not reported as error.

CAMEL-8137: Bean component should detect override methods that are assignable by type, so duplicate methods is not reported as error.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/46d464b4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/46d464b4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/46d464b4

Branch: refs/heads/master
Commit: 46d464b4619ad398259d4ce577bffbebfdfbb72d
Parents: f5bb673
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Dec 10 11:19:23 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Dec 10 11:19:23 2014 +0100

----------------------------------------------------------------------
 .../apache/camel/component/bean/BeanInfo.java   | 28 +++++++++++++-------
 1 file changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/46d464b4/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 7f74407..402e738 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
@@ -299,7 +299,14 @@ public class BeanInfo {
         LOG.trace("Introspecting class: {}", clazz);
 
         // favor declared methods, and then filter out duplicate interface methods
-        Set<Method> methods = new HashSet<Method>(Arrays.asList(clazz.getDeclaredMethods()));
+        List<Method> methods;
+        if (Modifier.isPublic(clazz.getModifiers())) {
+            LOG.trace("Preferring class methods as class: {} is public accessible", clazz);
+            methods = new ArrayList<Method>(Arrays.asList(clazz.getDeclaredMethods()));
+        } else {
+            LOG.trace("Preferring interface methods as class: {} is not public accessible", clazz);
+            methods = getInterfaceMethods(clazz);
+        }
 
         // it may have duplicate methods already in the declared list of methods, so lets remove those
         Set<Method> overrides = new HashSet<Method>();
@@ -318,17 +325,20 @@ public class BeanInfo {
         methods.removeAll(overrides);
         overrides.clear();
 
-        List<Method> extraMethods = getInterfaceMethods(clazz);
-        for (Method target : extraMethods) {
-            for (Method source : methods) {
-                if (ObjectHelper.isOverridingMethod(source, target, false)) {
-                    overrides.add(target);
+        if (Modifier.isPublic(clazz.getModifiers())) {
+            // add additional interface methods
+            List<Method> extraMethods = getInterfaceMethods(clazz);
+            for (Method target : extraMethods) {
+                for (Method source : methods) {
+                    if (ObjectHelper.isOverridingMethod(source, target, false)) {
+                        overrides.add(target);
+                    }
                 }
             }
+            // remove all the overrides methods
+            extraMethods.removeAll(overrides);
+            methods.addAll(extraMethods);
         }
-        // remove all the overrides methods
-        extraMethods.removeAll(overrides);
-        methods.addAll(extraMethods);
 
         // now introspect the methods and filter non valid methods
         for (Method method : methods) {