I've got a couple of projects that use Guice that used to use manual DI. 
 So currently I have one module class with all the bindings.  I often use 
the annotatedWith(Names.named("MyClass")) approach so I can specify which 
implementation should be injected.

But this brings me to the problem.  What if I have the case where several 
injections much change as a set?  E.g. lets say I'm implementing a couple 
of pricing strategies where each strategy creates 5 concrete classes...it's 
critical that all 5 of those are from the same pricing strategy...not 4 
from one and 1 from another.  In the old days, pre-Guice, I could just go 
to my 'application construction method' find the 5 relevant classes put 
them right next to each other in code...add comments/etc.  E.g. everything 
was all in one place so it was manageable to find what types are being 
created and switch things out.

Now post-Guice I have no centralized control of anything...as the module 
file doesn't say what is created it just says if 'you' find X use Y.  The 
real control is in each java class file's @Inject constructor where I add 
the  @Named("MyClass") annotation.

How can I achieve a more centralized control over the exact classes 
instantiated?


-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-guice/-/PHofIXp_71AJ.
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