Just tried out the current HI from trunk, I don't get the child child
injector to respect the singleton. Am I missing something?
The code
Injector injector = Guice.createInjector(new AbstractModule() {
protected void configure() {
bind(EnergySource.class).to(Plutonium.class);
bind(DeLorean.class).in(Singleton.class);
}
});
Injector childInjector = Guice.createInjector(injector);
Injector childChildInjector = Guice.createInjector(childInjector,
new AbstractModule() {
protected void configure() {
// provision exception if this is not declared?
bind(EnergySource.class).to(LightningBolt.class);
}
});
injector.getInstance(DeLorean.class) ==
childInjector.getInstance(DeLorean.class)
but
childInjector.getInstance(DeLorean.class) !=
childChildInjector.getInstance(DeLorean.class)
the constructor of DeLorean gets called 2 times. Would have expected
it to work all the way down, it's turtles all the way down:)
Cheers,
Alen
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---