camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Propose add annotation @BeanInject
Date Tue, 12 Nov 2013 17:14:43 GMT
On Mon, Nov 11, 2013 at 9:22 PM, alexey-s <alexins@mail.ru> wrote:
> Hi
>
> Each framework has its own set of annotations to insert objects.
> 1) OSGI bluprint have annotation @Bean
> 2) Spring have annotation @Autowire
> 3) CDI Weld and Guice have annotation @Inject
> 4) EJB have annotations @EJB and @Resource
> This zoo annotations are not universal.
>

Yeah the IoC annotation world is a bit scattered and leaving people
confused with different choices,
and not sure which JAR has what annotations and what package they are from.

> I'm not looking Varant use annotations in project.
> As an example, take the JUnit test.
> Hard to raise test Java EE and WEB, to test the CDI (Weld).
> Hard to raise test OSGI Enterprise V4.2.
> It is easier to raise the Spring. A little harder to Guice.
>
> I offered a small revision. Instead of code
>   Bean bean = CamelContextHelper.mandatoryLookup (getContext (), "bean",
> Bean.class);
> we can write beautifully
>   @BeanInjection ("bean") Bean bean;
>

Yeah for Camel end users it could somewhat be nice with this
annotation. Though if we go down that road, we just add more IoC
annotations to the "zoo" of choices today.

And @BeanInject would be agnostic to whatever runtime you use, as it
just relies on camel-core. And would work similar to as
@EndpointInject / @PropertyInject and the others we have.


> As an example of similar implementation, I show the work of the annotation
> @PropertyInject.
> Instead of code
>    String stringValue = CamelContextHelper.parseText (getContext (),
> "{{property_a}}");
>    int intValue = CamelContextHelper.parseInteger (getContext (),
> "{{property_b}}");
> we can write beautifully
>    @PropertyInject ("property_a") String stringValue;
>    @PropertyInject ("property_b") int intValue;
>
> So the code looks beautiful. It is necessary to do so that your work is not
> only worked well, but also look nice.
>
>
> Aleksey
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Propose-add-annotation-BeanInject-tp5742782p5743064.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Mime
View raw message