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/10/24 16:00:35 UTC

[1/3] camel git commit: CAMEL-9243: Invocation of Bean fails when Bean extends and abstract which implements the actual method. Thanks to Alex Paransky for unit test.

Repository: camel
Updated Branches:
  refs/heads/camel-2.15.x 4cbc8cd26 -> d9a19d70c
  refs/heads/camel-2.16.x d90d0ad42 -> 5005e3f74
  refs/heads/master 9ff11b57f -> 1957a8282


CAMEL-9243: Invocation of Bean fails when Bean extends and abstract which implements the actual method. Thanks to Alex Paransky for unit test.


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

Branch: refs/heads/master
Commit: 1957a8282e6681edd8f547e225bda66feb640173
Parents: 9ff11b5
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Oct 24 15:59:01 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Oct 24 16:02:11 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/component/bean/BeanInfo.java   |  4 ++-
 .../component/bean/BeanHandlerMethodTest.java   | 34 ++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1957a828/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 d3c7214..a2f6ce8 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
@@ -987,7 +987,9 @@ public class BeanInfo {
         Iterator<MethodInfo> it = methods.iterator();
         while (it.hasNext()) {
             MethodInfo info = it.next();
-            if (Modifier.isAbstract(info.getMethod().getModifiers())) {
+            // if the class is an interface then keep the method
+            boolean isFromInterface = Modifier.isInterface(info.getMethod().getDeclaringClass().getModifiers());
+            if (!isFromInterface && Modifier.isAbstract(info.getMethod().getModifiers())) {
                 // we cannot invoke an abstract method
                 it.remove();
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/1957a828/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
index c0300dc..4b7f69a 100644
--- a/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
@@ -28,6 +28,16 @@ import org.apache.camel.impl.DefaultExchange;
  */
 public class BeanHandlerMethodTest extends ContextTestSupport {
 
+    public void testInterfaceBeanMethod() throws Exception {
+        BeanInfo info = new BeanInfo(context, MyConcreteBean.class);
+
+        Exchange exchange = new DefaultExchange(context);
+        MyConcreteBean pojo = new MyConcreteBean();
+        MethodInvocation mi = info.createInvocation(pojo, exchange);
+        assertNotNull(mi);
+        assertEquals("hello", mi.getMethod().getName());
+    }
+
     public void testNoHandleMethod() throws Exception {
         BeanInfo info = new BeanInfo(context, MyNoDummyBean.class);
 
@@ -97,6 +107,30 @@ public class BeanHandlerMethodTest extends ContextTestSupport {
         }
     }
 
+    public interface MyBaseInterface {
+
+        @Handler
+        String hello(@Body String hi);
+
+    }
+
+    public abstract static class MyAbstractBean implements MyBaseInterface {
+
+        public String hello(@Body String hi) {
+            return "Hello " + hi;
+        }
+
+        public String doCompute(String input) {
+            fail("Should not invoke me");
+            return null;
+        }
+
+    }
+
+    public static class MyConcreteBean extends MyAbstractBean {
+
+    }
+
     public static class MyNoDummyBean {
 
         public String hello(@Body String hi) {


[3/3] camel git commit: CAMEL-9243: Invocation of Bean fails when Bean extends and abstract which implements the actual method. Thanks to Alex Paransky for unit test.

Posted by da...@apache.org.
CAMEL-9243: Invocation of Bean fails when Bean extends and abstract which implements the actual method. Thanks to Alex Paransky for unit test.


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

Branch: refs/heads/camel-2.15.x
Commit: d9a19d70c882204b3e7dc2962ded004a49d62e06
Parents: 4cbc8cd
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Oct 24 15:59:01 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Oct 24 16:03:08 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/component/bean/BeanInfo.java   |  4 ++-
 .../component/bean/BeanHandlerMethodTest.java   | 34 ++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d9a19d70/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 d3c7214..a2f6ce8 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
@@ -987,7 +987,9 @@ public class BeanInfo {
         Iterator<MethodInfo> it = methods.iterator();
         while (it.hasNext()) {
             MethodInfo info = it.next();
-            if (Modifier.isAbstract(info.getMethod().getModifiers())) {
+            // if the class is an interface then keep the method
+            boolean isFromInterface = Modifier.isInterface(info.getMethod().getDeclaringClass().getModifiers());
+            if (!isFromInterface && Modifier.isAbstract(info.getMethod().getModifiers())) {
                 // we cannot invoke an abstract method
                 it.remove();
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/d9a19d70/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
index c0300dc..4b7f69a 100644
--- a/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
@@ -28,6 +28,16 @@ import org.apache.camel.impl.DefaultExchange;
  */
 public class BeanHandlerMethodTest extends ContextTestSupport {
 
+    public void testInterfaceBeanMethod() throws Exception {
+        BeanInfo info = new BeanInfo(context, MyConcreteBean.class);
+
+        Exchange exchange = new DefaultExchange(context);
+        MyConcreteBean pojo = new MyConcreteBean();
+        MethodInvocation mi = info.createInvocation(pojo, exchange);
+        assertNotNull(mi);
+        assertEquals("hello", mi.getMethod().getName());
+    }
+
     public void testNoHandleMethod() throws Exception {
         BeanInfo info = new BeanInfo(context, MyNoDummyBean.class);
 
@@ -97,6 +107,30 @@ public class BeanHandlerMethodTest extends ContextTestSupport {
         }
     }
 
+    public interface MyBaseInterface {
+
+        @Handler
+        String hello(@Body String hi);
+
+    }
+
+    public abstract static class MyAbstractBean implements MyBaseInterface {
+
+        public String hello(@Body String hi) {
+            return "Hello " + hi;
+        }
+
+        public String doCompute(String input) {
+            fail("Should not invoke me");
+            return null;
+        }
+
+    }
+
+    public static class MyConcreteBean extends MyAbstractBean {
+
+    }
+
     public static class MyNoDummyBean {
 
         public String hello(@Body String hi) {


[2/3] camel git commit: CAMEL-9243: Invocation of Bean fails when Bean extends and abstract which implements the actual method. Thanks to Alex Paransky for unit test.

Posted by da...@apache.org.
CAMEL-9243: Invocation of Bean fails when Bean extends and abstract which implements the actual method. Thanks to Alex Paransky for unit test.


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

Branch: refs/heads/camel-2.16.x
Commit: 5005e3f74f13df21ac12e92158e5e568bbade313
Parents: d90d0ad
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Oct 24 15:59:01 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Oct 24 16:02:35 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/component/bean/BeanInfo.java   |  4 ++-
 .../component/bean/BeanHandlerMethodTest.java   | 34 ++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5005e3f7/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 d3c7214..a2f6ce8 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
@@ -987,7 +987,9 @@ public class BeanInfo {
         Iterator<MethodInfo> it = methods.iterator();
         while (it.hasNext()) {
             MethodInfo info = it.next();
-            if (Modifier.isAbstract(info.getMethod().getModifiers())) {
+            // if the class is an interface then keep the method
+            boolean isFromInterface = Modifier.isInterface(info.getMethod().getDeclaringClass().getModifiers());
+            if (!isFromInterface && Modifier.isAbstract(info.getMethod().getModifiers())) {
                 // we cannot invoke an abstract method
                 it.remove();
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/5005e3f7/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
index c0300dc..4b7f69a 100644
--- a/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
@@ -28,6 +28,16 @@ import org.apache.camel.impl.DefaultExchange;
  */
 public class BeanHandlerMethodTest extends ContextTestSupport {
 
+    public void testInterfaceBeanMethod() throws Exception {
+        BeanInfo info = new BeanInfo(context, MyConcreteBean.class);
+
+        Exchange exchange = new DefaultExchange(context);
+        MyConcreteBean pojo = new MyConcreteBean();
+        MethodInvocation mi = info.createInvocation(pojo, exchange);
+        assertNotNull(mi);
+        assertEquals("hello", mi.getMethod().getName());
+    }
+
     public void testNoHandleMethod() throws Exception {
         BeanInfo info = new BeanInfo(context, MyNoDummyBean.class);
 
@@ -97,6 +107,30 @@ public class BeanHandlerMethodTest extends ContextTestSupport {
         }
     }
 
+    public interface MyBaseInterface {
+
+        @Handler
+        String hello(@Body String hi);
+
+    }
+
+    public abstract static class MyAbstractBean implements MyBaseInterface {
+
+        public String hello(@Body String hi) {
+            return "Hello " + hi;
+        }
+
+        public String doCompute(String input) {
+            fail("Should not invoke me");
+            return null;
+        }
+
+    }
+
+    public static class MyConcreteBean extends MyAbstractBean {
+
+    }
+
     public static class MyNoDummyBean {
 
         public String hello(@Body String hi) {