Hi Billy Charles Moulliard is working on a camel-cdi component. So I guess the questions to make the bean and beanRef more modern to the worlds of OSGi and CDI could make sense.
Either we could do 1) Ensure all lookups is done only from beanRef (to refer to something that is being looked up). And then leave .bean as to invoke an existing bean. eg we @deprecated the .bean(class) and .bean(String) methods. 2) Let .bean be able to lookup as well as if you are using .beanRef. So this will adjust .bean(class) to lookup instead of currently to instantiate a new instance from the class. This is a API breaking and thus can only be done in next release. And we need to indicate this in the release notes. The .bean(class) was also mostly added because back then we were lazy in unit testing, and just wanted Camel to invoke a bean, without the need to setup the registry and whatnot. I do not know how many uses it for real as well? 3) Anyway for CDI and OSGi we should possible also add a way to specify that filter discrimination. On Mon, Jan 9, 2012 at 12:49 PM, Billy <[email protected]> wrote: > Hi again Claus, > > Yes, I also think that this is a neat concept and fits well with the > "de-Spring-ification" that Camel is currently undergoing. > > I also noted that the registry has the type lookup option, which led me to > believe that it could be used from the routes as well. My implementation of > the registry SPI is basically a rip of the project I mentioned in the last > post: > > https://github.com/obergner/camelpe/blob/master/impl/src/main/java/net/camelpe/extension/camel/spi/CdiRegistry.java > https://github.com/obergner/camelpe/blob/master/impl/src/main/java/net/camelpe/extension/camel/spi/CdiRegistry.java > > Seems like the author has come a long way of integrating Camel with CDI, > using i.e. CDI to scan for type converters, routes contexts etc. My need was > much more basic so I opted to only use the registry to reference my business > beans for the routes. Perhaps his work could be merged into a camel-cdi > component if the author would like to contribute? > > I can only agree that the bean options are confusing, especially with > regards to when the registry is used and when Camel will take care of > instantiating classes. This obviously plays a large role if the bean has > dependencies and in multi concurrent scenarios (are my objects scoped as > singletons/prototypes, etc..). > > Would love to continue the discussion, thanks for your response! > > /Billy > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Typesafe-Bean-injection-in-routes-using-Registry-tp5092420p5131160.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/
