Hi guys (and gal's ;-)!

I've been experimenting lately with utilizing CDI as my Camel bean registry,
making it effective in an Java EE 6 context. Seems I was not the only one as
I've noticed both the JBoss Switchyard guys as well as this 
https://github.com/obergner/camelpe/wiki project  seems to have the same
philosophy.

After implementing the registry SPI and hooking it up to the CDI BeanManager
I could sucessfully inject my beans into a route using i.e.

@Named("myBean")
class SomeBusinessBean etc...

from("something").beanRef("myBean")

This really comes in handy using @Producer annotations to create factories
for my beans, i.e.

@Produces @Named("myBean")
public SomeBusinessBean createBusinessBean(){...}

This is all well, but I was kind of confused when I found out that
.bean(SomeBusinessBean.class) does not utilize the registry for lookups, but
rather instantiates the objects by itself.

>From my understanding the beanRef method however looks in the registry but
does not have a type-safe way of looking it up as it's only used to look up
by String name references.

I could theoretically inject my beans in the routebuilder, i:e

@Inject SomeBusinessBean myBeanObject

configure(){
    from("somewhere").bean(myBeanObject)
}

...but I guess that this creates a singleton bean as it is given at route
definition?

Are my assumptions correct that I should only use the beanRef(String.class)
method, or am I missing something obvious?

Would i.e. a beanRef(SomeBusinessBean.class) extension be possible (or even
a good thing?), using type-safety and Registry lookup's?

--
View this message in context: 
http://camel.465427.n5.nabble.com/Typesafe-Bean-injection-in-routes-using-Registry-tp5092420p5092420.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to