On Jun 2, 2:00 pm, Dmitry Skavish <[email protected]> wrote: > I am specifying it in the child module. It does not seem to matter. > The only thing which matters is component's dependencies. If they all > can be injected from the parent then the component will be created in > parent. I believe this is a bug. If I explicitly bind component in a > child it should be created in a child. I will try to create a test > case for that and post it here.
We've got fairly extensive tests for this stuff. Anything that's bound in a child injector will be created in the child injector, so long as the child injector exists. I wrote a test for the ChildScope issue; it demonstrates that an annotated class is created in the child injector as you've requested. http://code.google.com/p/google-guice/source/diff?spec=svn993&r=993&format=side&path=/trunk/test/com/google/inject/ParentInjectorTest.java I admit that this behaviour can be confusing - it's difficult to guess which injector will own the binding. For that reason I strongly recommend using explicit bindings for everything that should be satisfied by child injectors. The reason I chose this behaviour is that it's the least bad of two potentially surprising behaviours. Although it can be frustrating that child injectors share singletons by default, it may be dangerous if they didn't. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
