On May 22, 12:38 pm, Aleksey Didik <[email protected]> wrote:
> Whenever possible? Why in my example ManagerImpl was created in child
> injector (two different singletons), but BuilderImpl was created in
> ancestor (one singleton for both trees)? Both is just-in-time
> bindings, isn't it?

The ManagerImpl cannot be created in the parent injector because its
dependencies aren't there (Builder.class is only available in the
child).
But BuilderImpl doesn't have any dependencies, and so it'll be created
in the parent injector.

For explicit bindings, where it's bound is where it'll be.
For just-in-time bindings (JIT bindings), it'll be bound at the
highest ancestor that satisfies all dependencies.

Because the JIT case is so, unpredictable, I recommended explicit
bindings for child injectors.
--~--~---------~--~----~------------~-------~--~----~
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