Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 009C718DD9 for ; Sat, 24 Oct 2015 14:00:36 +0000 (UTC) Received: (qmail 2352 invoked by uid 500); 24 Oct 2015 14:00:35 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 2288 invoked by uid 500); 24 Oct 2015 14:00:35 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 2275 invoked by uid 99); 24 Oct 2015 14:00:35 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Oct 2015 14:00:35 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3D08BDFFC2; Sat, 24 Oct 2015 14:00:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Date: Sat, 24 Oct 2015 14:00:35 -0000 Message-Id: <73a1aee2398442dcbd92f3287f731f36@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [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 Authored: Sat Oct 24 15:59:01 2015 +0200 Committer: Claus Ibsen 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 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) {