camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "james strachan (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CAMEL-5553) support injection of Endpoint and @Produce @Consume annotations
Date Mon, 03 Sep 2012 15:51:07 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-5553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13447326#comment-13447326
] 

james strachan edited comment on CAMEL-5553 at 9/4/12 2:51 AM:
---------------------------------------------------------------

I hit some issues when using @Inject with @EndpointInject / @Produce and with @Named so things
are now much simpler.

Use either of these 2 combinations of annotations for Endpoint / ProducerTemplate injection:

* the traditional Camel injections (@EndpointInject, @Produce) 
* @Inject (from CDI) plus a qualifier:
  * @Named (from CDI for the named 'ref' style from Camel)
  * @Uri("some:url") 
  * @Mock("mock:optionaUriGoesHere") for mock endpoint injection

So you can inject via @Inject via...

{code}
public class Foo {
  @Inject @Named("someRef") Endpoint a;
  @Inject @Uri("seda:foo") Endpoint b;
  @Inject @Mock MockEndpoint result; // mock:result
  @Inject @Mock("mock:another") MockEndpoint c; // mock:another

  @Inject Uri("seda:bar") ProducerTemplate producer;
{code}




                
      was (Author: jstrachan):
    I hit some issues when using @Inject with @EndpointInject / @Produce and with @Named so
things are now much simpler:

Either use the traditional Camel injections (@EndpointInject, @Produce) or use @Inject from
CDI plus a qualifier; the supported qualifiers are @Named (from CDI for the named 'ref' style
from Camel), @Uri("some:url"), @Mock("mock:optionaUriGoesHere")

So you can inject via @Inject via...

{code}
public class Foo {
  @Inject @Named("someRef") Endpoint a;
  @Inject @Uri("seda:foo") Endpoint b;
  @Inject @Mock MockEndpoint result; // mock:result
  @Inject @Mock("mock:another") MockEndpoint c; // mock:another

  @Inject Uri("seda:bar") ProducerTemplate producer;
{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

Mime
View raw message