Comment #3 on issue 353 by tregubov: Strange behavior on Inject Injector  
instance in Constructor
http://code.google.com/p/google-guice/issues/detail?id=353

I create little Example with BAG. You can see it in attachment.

You can reproduce the Bag here
static class ChildService1Impl implements ChildService1
     {
         @Inject
         public ChildService1Impl(Injector injector)  /*BAG*/
//        public ChildService1Impl(Injector injector,ChildService2Impl  
childService2)
/*ALL WORK*/
         {
             System.out.println(injector.getParent());
         }
     }

When You in /*BAG*/ version you got null in System.out. Mean Root Injector
But when you run /*ALL WORK*/ version you got

Injector[bindings=[ProviderInstanceBinding[key=Key[type=com.google.inject.Injector,
annotation=[none]], source=[unknown source], scope=Scopes.NO_SCOPE,
provider=Provider<Injector>],
ProviderInstanceBinding[key=Key[type=java.util.logging.Logger,  
annotation=[none]],
source=[unknown source], scope=Scopes.NO_SCOPE, provider=Provider<Logger>],
InstanceBinding[key=Key[type=com.google.inject.Stage, annotation=[none]],
source=[unknown source], instance=DEVELOPMENT],
ProviderInstanceBinding[key=Key[type=ru.faulab.fmsgenerator.GuiceBagExample$IRootServ
iceFactory, annotation=[none]],
source=ru.faulab.fmsgenerator.GuiceBagExample$RootSubModule1.configure(GuiceBagExampl
e.java:52), scope=Scopes.SINGLETON,
provider=ru.faulab.fmsgenerator.GuiceBagExample$IRootServiceFactory for
ru.faulab.fmsgenerator.GuiceBagExample$IRootServiceImpl],
LinkedKeyBinding[key=Key[type=ru.faulab.fmsgenerator.GuiceBagExample$IRootService2,
annotation=[none]],
source=ru.faulab.fmsgenerator.GuiceBagExample$RootSubModule2.configure(GuiceBagExampl
e.java:60), scope=Scopes.SINGLETON,
target=Key[type=ru.faulab.fmsgenerator.GuiceBagExample$IRootService2Impl,
annotation=[none]]]]] in System Out. Mean Child Injector



Attachments:
        GuiceBagExample.java  3.0 KB

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" 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-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to