Comment by
mccu...@gmail.com:
It would go something like this:
{{{
public class RemoteFooModule extends AbstractModule {
private final String fooServer;
public RemoteFooModule(String fooServer) {
this.fooServer = fooServer;
}
@Override protected void configure() {
bind(String.class).annotatedWith(named("fooServer")).toInstance(fooServer);
bind(FooService.class).to(RemoteFooService.class);
}
}
}}}
{{{
public class InMemoryFooModule extends AbstractModule {
@Override protected void configure() {
bind(FooService.class).to(InMemoryFooService.class);
}
}
}}}
Then in your bootstrap code that selects the application modules and calls
{{{Guice.createInjector(modules);}}} you would choose whether to add the
RemoteFooModule or InMemoryFooService depending on the application's
properties/arguments/environment.