--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice...@googlegroups.com.
To post to this group, send email to google...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/b8e3782d-53f9-42a4-b0d4-8e148c56323d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
public class Example implements ExampleInterface {
private final int moduleId;
public Example(int moduleId){
this.moduleId = moduleId;
}
}
@Provides @Module1
private ExampleInterface provideModule1Example(@Module1 int moduleId){
return new Example(moduleId);
}
@Provides @Module2
private ExampleInterface provideModule2Example(@Module2 int moduleId){
return new Example(moduleId);
}public interface ExampleInterfaceFactory {
ExampleInterface create(Object someParameter);
}class Foo {@Injectpublic Foo(FooService fooService, @Assisted String name) { ... }public static interface Factory {Foo createFoo(String name);}}public class FooManager {private final Foo.Factory _fooFactory;@Injectpublic FooManager(Foo.Factory factory) {_fooFactory = factory;}public Foo onFooSubscribed(String subscriptionName) {Foo foo = _fooFactory.create(subscriptionName);// TODO: save foo for later.return foo;}}
public class ClientFactory {private final Injector _injector;@Injectpublic ClientFactory(Injector injector) {_injector = injector;}public Client create(ClientConfiguration config) {return _injector.createChildInjector(new ClientModule(config)).getInstance(Client.class);}private static class ClientModule extends AbstractModule {...}}
public class ClientManager {private final ClientFactory _clientFactory;@Injectpublic ClientManager(ClientFactory factory) {_clientFactory = factory;}public Client onClientSubscribed(ClientConfiguration clientConfig) {Client client = _clientFactory.create(clientConfig);client.start();// TODO: save client for later.return client;}}
public Bar(String name) { ... }}
public class BarManager {public Bar onBarSubscribed(String barName) {Bar bar = new Bar(barName);// TODO: save bar for later.return bar;}}
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/57836ae8-302b-4571-967c-1d94e94214f8%40googlegroups.com.