Ha! That makes perfect sense, and completely obviates the need for what I was asking for. So, blah -- good job making a consistent no-frills API. :-)
On a somewhat related, but mostly different note, in profiling & performance tuning we've seen a lot of overhead from Provider.get calls. This is usually related to a lot of creation of throwaway Errors objects. I'm not sure what, if anything, can be done about this. In the case of AssistedInject there's even worse overhead by trying to bind objects to the parent injector that will always fail & then be created in the child injector. In those instances, I think an additional InjectorBuilder.setJitBindingsEnabled(false) API would do wonders (and also solve a lot of conceptual difficulties people have had with child injectors adding bindings to the parent). Sam On Tue, Sep 15, 2009 at 8:21 PM, [email protected] <[email protected]>wrote: > > On Sep 15, 11:51 am, Sam Berlin <[email protected]> wrote: > > That's one way of doing it. I suppose it'd work, too, so long as > provideFoo > > wasn't marked as a singleton (because we do want Foo to change through > its > > lifetime). But, it has the sort-of-bad behavior of effectively creating > two > > Providers for Foo, the ProviderMethod provider & the real Provider. > > One thing to keep in mind - whenever you bind a Provider<Foo> and then > inject a Provider<Foo>, you get different provider instances. To > illustrate: > final FooProvider a = new MyFooProvider(); > Injector injector = Guice.createInjector(new AbstractModule() { > public void configure() { > bind(Foo.class).toProvider(a); > } > }); > Provider<Foo> b = injector.getProvider(Foo.class); > assertFalse(a == b); > assertFalse(b instanceof FooProvider); > > With scopes, the difference is even more pronounced. If we were to > scope the Foo binding in singleton scope, repeated calls to a.get() > would still return different instances. > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
