Hi

I would like to discuss this a bit. I think its an interesting thought.
The old school spring IoC stuff did not really offer a lookup by type-only.
But now the new kids on the block like CDI and OSGi offers that.

My first wish would be that we had a out of the box camel-cdi component :).

We may add a type safe bean ref lookup by the class name.
In fact the org.apache.camel.spi.Registry SPI have a method to lookup
by type only.

One caveat is that the DSL is rather big already for bean/method call
expressions.
So we should be careful to now cause the end user to get lost in all
the options (eg all the methods for bean/beanRef/method etc.)

However if we go down this route, we should make sure to more clearly
document on the javadoc, and in the wiki documentation
what the diff lookup methods does.

And btw we love contributions, so patches is welcome :)


On Wed, Dec 21, 2011 at 5:57 PM, Billy <[email protected]> wrote:
> 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.



-- 
Claus Ibsen
-----------------
FuseSource
Email: [email protected]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to