My problem with camels built in guice was, i could not control the start of
the context. This happens as soon as guice begins - within the module you
are extending (calling run is not necessary).
So my alternate solution to use guice is: I extended
org.apache.camel.main.Main and injected my bound context there.
My main looks like this:

public class GuiceMain extends Main {

    /**
     * Injected context.
     */
    @Inject
    private CamelContext context;

    /**
     * Addes the main route that contains all others.
     */
    @Inject
    private RouteBuilder routes;

    @Override
    protected final CamelContext createContext() {
        return context;
    }

}

In this method you could also do aother things to prapre/set up the context
before returning it. With this nothing is started before you call
main.run().

so in my module (extends AbstractModule) i just added
bind(CamelContext.class).to(DefaultCamelContext.class).in(Singleton.class);

and my jndi.properties contains the default value:
java.naming.factory.initial =
org.apache.camel.util.jndi.CamelInitialContextFactory




--
View this message in context: 
http://camel.465427.n5.nabble.com/Setting-up-CamelContext-with-Guice-tp5764709p5764817.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to