You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Steve973 <st...@gmail.com> on 2016/06/07 19:43:47 UTC
camel-guice and injecting the CamelContext into a @Provides method in
the module
Hello! I am attempting to convert my Camel application to Guice, and there
are some things that I am missing when I read the documentation. Most of
the examples that I see make use of a jndi.properties file and they use
this along with something like a CamelModuleWithMatchingRoutes extension to
bootstrap their application. I need to do other things when my application
starts up, so I prefer to create a CamelModuleWithMatchingRoutes extension,
then create an Injector instance in a main() method with it. Some of the
objects in my graph require a CamelContext instance in their constructor,
and I was wondering if this was possible. When I have used Guice and Camel
together in the past, I could create the Injector instance, and then get an
instance of the CamelContext through that (in the main method), but I would
like to have access to the CamelContext at Guice-config time, rather than
after the module has been instantiated. I tried creating a @Provides
method with an Injector as a parameter, but this doesn't seem to be
working. Should it work this way, or should I be doing something
differently?
Thanks,
Steve