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

On Thursday, April 11, 2013 12:21:20 AM UTC+2, Newbie McBozo wrote:
>
> I'm working with an application that uses Guice.
>
> I know nothing about guice, and parsing the documentation for my 
> particular situation hasn't been easy.
>
> I have a java class.  That class needs an object provided by the 
> application.
>
> If I subclass an application provided class and override it's binding, 
> obtaining the object is a matter of 
> @Inject 
> AppObject ao
>
> Within my own classes, if I try that, the injected object is null.
>
> How do I set up my own classes so that when I instantiate them, the 
> injected fields are resolved?
>
> I imagine that I need to bind my class, but I'm having difficulty figuring 
> it how to do that without spending time learning way more about Guice than 
> this fairly simple (and I imagine common) situation really should require.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to