Jesse,

Is this the same reason that prevents child injectors using
bind(Interface.class).to(Impl.class) from having the Impl eagerly created if
the parent injector is using Stage.PRODUCTION?

Sam

On Fri, May 22, 2009 at 12:15 PM, [email protected] <[email protected]>wrote:

>
> Short version: add the following statement to your private module and
> you'll get your desired behaviour.
>  bind(ManagerImpl.class);
>  bind(BuilderImpl.class);
>
> Longer version:
> When you say: bind(Foo.class).to(FooImpl.class), you're creating an
> explicit binding for Foo that links to a just-in-time binding for
> FooImpl. From the Injector.createChildInjector() javadoc,
>  Just-in-time bindings created for child injectors will be created in
> an ancestor injector whenever possible. This allows for scoped
> instances to be shared between injectors. Use explicit bindings to
> prevent bindings from being shared with the parent injector.
> Guice prefers to share bindings whenever it has the opportunity. If
> it's creating a Just-in-time binding, it'll do so in the top-level
> injector wherever possible.
>
> I admit that this is somewhat mindboggling. Of the two possible
> behaviours, we went with this one because we prefer to err on the side
> of singletons really being singletons.
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to