Versions Compared

Key

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

...

You can create your own derivation of CamelModule which overloads the configureRoutes() method to allow you to use the Multibinder in Guice to bind different route builders.

Code Block
public static class MyModule extends CamelModule {
    /**
     * Lets add the routes
     */
    @Override
    protected void configureRoutes(Multibinder<Routes> binder) {
        binder.addBinding().to(MyHardcodeRoute.class);
        binder.addBinding().to(MyRouteInstaller.class);
    }
}
...
Injector injector = Guice.createInjector(new MyModule());

Though since the above only binds RouteBuilder classes there is no real nead to create this derived class. We could replace the above code with just

Code Block

Injector injector = Guice.createInjector(new CamelModule(MyRouteBuilder.class, AnotherRouteBuilder.class));

Creating multiple RouteBuilder instances per type

...