Your object is injected deps if it is constructed by Guice in some way :
injector.getInstance, provider.get() , being constructed by guice as a
dependancy etc)

I you built an object with new obviously it's not injected.

There is a way, you can build an object in a module and then call
requestInjection(Object o). The injection constructor won't be used of
course but any field and method annotated are set afer injector
construction. But this should be last option (as is binding to instance).



2010/3/5 Eelco Hillenius <[email protected]>

> Bind the class instead of the instance, so that Guice instantiates the
> object, passing in dependencies in the process.
>
>
> > and GatewayPool:
> >
> > public class GatewayPool {
> >   @Inject
> >   private GatewaysConfiguration configuration;
> >    ......
> >   public GatewayPool {
> >      configuration.doSomething();
> >   }
> > }
> >
>
> That won't work, because you're trying to use a member in the
> constructor that is not yet initialized. Change this to:
>
> public class GatewayPool {
>
>  @Inject
>  public GatewayPool(GatewaysConfiguration configuration) {
>     configuration.doSomething();
>  }
> }
>
>
> Eelco
>
> --
> 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]<google-guice%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
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.

Reply via email to