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 DF93618DD8 for ; Sat, 24 Oct 2015 14:00:35 +0000 (UTC) Received: (qmail 2442 invoked by uid 500); 24 Oct 2015 14:00:35 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 2304 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 2279 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 41003DFBE6; 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:36 -0000 Message-Id: In-Reply-To: <73a1aee2398442dcbd92f3287f731f36@git.apache.org> References: <73a1aee2398442dcbd92f3287f731f36@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [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. 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 Authored: Sat Oct 24 15:59:01 2015 +0200 Committer: Claus Ibsen 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 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) {