Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In this example we just write RouteBuilder implementations, then we write a Guice module MyModule to create the CamelContext, bind any RouteBuilder instances and configure any components and endpoints, then we create a jndi.properties file to bootstrap Guice and Camel.

...

What this does is boot up the Guice based JNDI provider from jndi.properties file on the classpath. This then bootstraps the Guice injector and loads whatever Guice modules are defined in the jndi.properties file - then injects the remaining properties in the file.

...

If you see the jms() method of the Guice MyModule you will see it is annotated with @Provides to indicate to Guice that it is a provider and it is annotated with @JndiBind("jms") to bind it to the JNDI name jms when it is created.

This method then configures the component. The provider method is parameterized by the @Named("activemq.brokerURL") property which is injected from the jndi.properties file. This lets you define the properties which should be environment specific (such as URLs, machine names, usernames/passwords and so forth) while leaving all of the other configuration which does not change in different environments in Java code.

...