You can use: Foo foo = new FooImpl(); bind(Foo.class).toInstance(foo);
This is an implicit singleton and you can use the same instance for multiple injectors. Alternativly you can use ChildInjectors. Cheers Noc Am 02.12.2011 15:00, schrieb Sandro Munda: > The @Singleton scope does not refer to the Singleton pattern. > > According to the "Dependency Injection" book of "Dhanji" : > > "Very simply, a singleton’s context is the injector itself. The > life of a singleton is tied to the life of the injector. Therefore, > only one instance of a singleton is ever created per injector. It is > important to emphasize this last point, since it is possible for > multiple injectors to exist in the same application. In such a > scenario, each injector will hold a different instance of the > singleton-scoped object." > > Thus, is it possible to share the same Singleton instance through > multiple modules and multiple injectors ? > > The same question is available on StackOverflow : > http://stackoverflow.com/questions/8356640/guice-how-to-share-the-same-singleton-instance-through-multiple-injectors-modu > > Thanks. > > Sandro Munda > <[email protected]> > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
