You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Romain Manni-Bucau <rm...@gmail.com> on 2012/07/05 00:57:28 UTC

camel cdi extension

Hi,

following a discussion on deltaspike IRC channel i created a small CDI
extension camel oriented -->
https://github.com/rmannibucau/camel-cdi-extension

the idea is to decorate route builders with @CamelContextConfig(contextName
= "xxxx") and then be able to get injected the context directly:

     @Inject
    @CamelContextId("context1")
    private CamelContext ctx1;


Currently the context is created when needed (injection time) and destroyed
with the application.

That's more a poc than something completely done but was to let you know (I
know some work is done and the question on the way to start a context is
not totally completed).

- Romain

Re: camel cdi extension

Posted by Charles Moulliard <cm...@gmail.com>.
Hi Romain,

This is really interesting what you have have developed. I don't really like
how you add RouteBuilder in the create method (class CamelContextBean) and I
would prefer that the user can provide this information like we do in a more
Camel traditional way. By the way, I suggest that in the CamelContextBean
class (method create) we use CdiCamelContext as it implements Camel Registry
to do CDI bean lookup in the registry. 

@Inject
@CamelContextId("context1")
private CamelContext ctx1;

ctx1.addRoutes(new MyRouteBuilder())

Remark : camel-cdi (2.10) allows already to do this ;-)

@Inject
protected CdiCamelContext camelCtx;

@Inject
protected org.fusesource.example.cdi.camel.SimpleCamelRoute simpleRoute;
 ...

 simpleRoute.setTimerUri("timer://simple?fixedRate=true&period=10s");

 // Add Camel Route
 camelCtx.addRoutes(simpleRoute);

So what could be the benefit to use this CDI extension ?

I will have a look on that today.

Regards,

Charles

-----
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
--
View this message in context: http://camel.465427.n5.nabble.com/camel-cdi-extension-tp5715506p5715512.html
Sent from the Camel Development mailing list archive at Nabble.com.