Sorry - the wording is perhaps overstated. javax.inject.Provider is
merely a standardization of Guice's Provider in order to provide more
compatibility between different DI systems. They occupy the same space
in the design.
And I suppose it's not "internal" to Guice in that it is a public API,
but it is, nevertheless, a part of the DI mechanism. It is a part of
the framework itself rather than merely a signal like @Inject which, as
an annotation, is throw-away if you don't want to use it.
But more importantly, what it isn't is a generalized Factory interface
or pattern, though it bears a similarity to it. It also bears a
similarity to Supplier and any number of other "get me something"
patterns. My point is, it's distinct from the concept of Factory<T> or
Supplier<T> (or even Lazy<T> as Dagger has).
Christian.
>>>
http://code.google.com/p/**google-guice/wiki/**InjectingProviders<
http://code.google.com/p/google-guice/wiki/InjectingProviders>
>>>
>>>
>>> On 04/11/2013 04:33 AM, Newbie McBozo wrote:
>>>
>>>> Thanks for your help guys, I figured it out.
>>>>
>>>> The way I attacked this was this:
>>>>
>>>> I created a factory interface. I then added a line to the
>>>> configure
>>>> function of the module:
>>>>
>>>> binder.install(new FactoryModuleBuilder().build(**
>>>> MyClassFactory.class));
>>>>
>>>> rather than calling "new" for new instances of the class, I inject
>>>> a
>>>> factory and call MyClassFactory.create().
>>>>
>>>> I'm not explaining it very well, but my code is working. The
>>>> variables
>>>> that I was trying to inject are now resolving appropriately.
>>>>
>>>> On Wednesday, April 10, 2013 5:09:25 PM UTC-7, Newbie McBozo wrote:
>>>>
>>>> I get that, and forgive me for being dense, but I don't get how to
>>>> make it so that my class is created by Guice so that my injections
>>>> will work.
>>>>
>>>> I see that the application provides a module that's called on
>>>> startup. Within that module I see a series of functions that call
>>>> binder.bind and in all of those classes I see that injection works.
>>>>
>>>> Looking at that, I would think that I could binder.bind my own
>>>> class but that doesn't seem to work. I could have syntax issues,
>>>> but my sense is that there's a fundamental thing that I'm missing.
>>>>
>>>> On Wednesday, April 10, 2013 4:15:28 PM UTC-7, Thomas Broyer wrote:
>>>>
>>>> Dependency Injection 101: only objects created by the DI
>>>> container (Guice in this case) are injected; this means only
>>>> objects that have been retrieved from the Injector (through
>>>> its getInstance method generally) or have themselves been
>>>> injected into other classes. It's possible to inject objects
>>>> that you 'new' yourself (or more generally have not been
>>>> created by Guice itself), but again it has to be explicit:
>>>>
https://code.google.com/p/**google-guice/wiki/Injections#**
>>>> On-demand_Injection<
https://code.google.com/p/google-guice/wiki/Injections#On-demand_Injection>
>>>> <
https://code.google.com/p/**google-guice/wiki/Injections#**
>>>> On-demand_Injection<
https://code.google.com/p/google-guice/wiki/Injections#On-demand_Injection>
>>>> google-guice+unsubscribe@**
googlegroups.com<
google-guice%2Bunsu...@googlegroups.com>
>>>> .
>>>>
http://groups.google.com/**group/google-guice?hl=en<
http://groups.google.com/group/google-guice?hl=en>
>>>> .
>>>> For more options, visit
>>>>
https://groups.google.com/**groups/opt_out<
https://groups.google.com/groups/opt_out>
>>>> .
>>>>
>>>>
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups
>>> "google-guice" group.
>>> To unsubscribe from this group and stop receiving emails from it,
>>> send an
>>> email to
>>> google-guice+unsubscribe@**
googlegroups.com<
google-guice%2Bunsu...@googlegroups.com>
>>> .
>>>
http://groups.google.com/**group/google-guice?hl=en<
http://groups.google.com/group/google-guice?hl=en>
>>> .
>>> For more options, visit
>>>
https://groups.google.com/**groups/opt_out<
https://groups.google.com/groups/opt_out>
>>> .
>>>
>>
>>
>> Christian Gruber :: Google, Inc. :: Java Core Libraries :: Dependency
>> Injection
>> email:
cgr...@google.com :::: mobile:
+1 (646) 807-9839
>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups
>> "google-guice" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an
>> email to
>> google-guice+unsubscribe@**
googlegroups.com<
google-guice%2Bunsu...@googlegroups.com>
>> .
>>
http://groups.google.com/**group/google-guice?hl=en<
http://groups.google.com/group/google-guice?hl=en>
>> .
>> For more options, visit
>>
https://groups.google.com/**groups/opt_out<
https://groups.google.com/groups/opt_out>
>> .
>>
>>
>>
>
> --
> You received this message because you are subscribed to the Google
> Groups "google-guice" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
google-guice...@googlegroups.com.