Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0371AD462 for ; Fri, 31 Aug 2012 13:07:13 +0000 (UTC) Received: (qmail 16227 invoked by uid 500); 31 Aug 2012 13:07:08 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 16177 invoked by uid 500); 31 Aug 2012 13:07:08 -0000 Mailing-List: contact issues-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 issues@camel.apache.org Received: (qmail 15980 invoked by uid 99); 31 Aug 2012 13:07:08 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 Aug 2012 13:07:08 +0000 Date: Sat, 1 Sep 2012 00:07:08 +1100 (NCT) From: "james strachan (JIRA)" To: issues@camel.apache.org Message-ID: <797968904.21994.1346418428635.JavaMail.jiratomcat@arcas> In-Reply-To: <1305512613.21462.1346405707869.JavaMail.jiratomcat@arcas> Subject: [jira] [Comment Edited] (CAMEL-5553) support injection of Endpoint and @Produce @Consume annotations MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-5553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13445905#comment-13445905 ] james strachan edited comment on CAMEL-5553 at 9/1/12 12:07 AM: ---------------------------------------------------------------- I've added a first spike to at least inject @Inject Endpoint instances which looks for @EndpointInject. Even this simple example is hard to get working in CDI to support Spring/Guice style support (e.g. injecting either Endpoint or MockEndpoint) - I've not yet found the magic way to let one @Produces function provide both Endpoint and MockEndpoint kinds of endpoints. e.g. so that both these styles can be used from the same plugin http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/MockEndpointInjectedBean.java?revision=1379437&view=markup http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointInjectedBean.java?revision=1379437&view=markup e.g. {code} public class Foo { @Inject @EndpointInject(uri = "mock:foo") private Endpoint foo; @Inject @EndpointInject(uri = "mock:bar") private MockEndpoint bar; ... } {code} since the @Produces method can produce either Endpoint or MockEndpoint but can't support both was (Author: jstrachan): I've added a first spike to at least inject @Inject Endpoint instances which looks for @EndpointInject. Even this simple example is hard to get working in CDI to support Spring/Guice style support (e.g. injecting either Endpoint or MockEndpoint) - I've not yet found the magic way to let one @Produces function provide both Endpoint and MockEndpoint kinds of endpoints. e.g. so that both these styles can be used from the same plugin http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/MockEndpointInjectedBean.java?revision=1379437&view=markup http://svn.apache.org/viewvc/camel/trunk/components/camel-cdi/src/test/java/org/apache/camel/cdi/support/EndpointInjectedBean.java?revision=1379437&view=markup e.g. {code} public class Foo { @Inject @EndpointInject(uri = "mock:foo") private Endpoint foo; @Inject @EndpointInject(uri = "mock:bar") private MockEndpoint bar; ... } {code} since the @Produces method can produce either Endpoint or MockEndpoint but can't support both {code} > support injection of Endpoint and @Produce @Consume annotations > --------------------------------------------------------------- > > Key: CAMEL-5553 > URL: https://issues.apache.org/jira/browse/CAMEL-5553 > Project: Camel > Issue Type: Improvement > Components: camel-cdi > Reporter: james strachan > > we don't yet support the various camel annotation injections in CDI yet; we should support the same capabilities as we have in spring/guice > http://camel.apache.org/bean-integration.html > http://camel.apache.org/bean-injection.html > I guess a more CDI way to do endpoint injection might be to have an annotation for endpointURI specification. Then you'd either use > {code} > public class MyBean { > // named reference injection > @Inject @Named("foo") Endpoint bar; > // URI based injection > @Inject @Uri("mock:whatnot") MockEndpoint foo; > ... > } > {code} > Rather than using the DI-agnostic @EndpointInject annotation - though I guess we could support it too (though having Inject twice looks a bit icky and not as DRY)... > {code} > public class MyBean { > // using current annotation... > @Inject @EndpointInject(uri = "mock:whatnot") MockEndpoint bar; > ... > } > {code} > For handling @Consume it would be nice to avoid having to use @Inject too as that seems a bit odd (since there's no injection going on). > For @Produce I guess we could support a straight @Inject of a ProcessorTemplate; allowing use of @Uri annotation to specify the default URI to send to -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira