On Thursday, March 17, 2011 5:28:48 AM UTC-7, Witold Szczerba wrote:
>
> Thanks for response, guys. The only problem is that your solutions are
> pre-injector construction, but in my case I have to provide Injector
> first and then be prepared for handling dependencies which were not
> mentioned in modules.
>

This is not a problem, actually. If you need a dependencies it is *
necessarily* mentioned in a module. If not within a bind(), then within an 
@Inject field of the bound class. So, during SPI-inspection, you query every 
bound class for its dependencies (see Guice's HasDependencies interface) and 
you collect them. At the end of the inspection process you have a list of 
everything that was bound and every dependencies that was *not *bound. You 
provide the bindings for the latter. (If the bindings you generate include 
dependencies of their own, you will have to recurse the process.)

In fact, this is precisely what jukito does and it works perfectly.

The only problem is if you do not know what class you want to bind until 
runtime. But for such a case, I agree with mccull that a factory would be a 
better tool.

Cheers!

    Philippe

>

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