Comment by [email protected]:
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.
For more information:
https://code.google.com/p/google-guice/wiki/AvoidConditionalLogicInModules
--
You received this message because you are subscribed to the Google Groups
"google-guice-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.