You can do things like this with Guice 4's ProvisionListener.  I did that 
once, so that classes or packages could be annotated with a "namespace" 
that determined where properties they wanted injected would be loaded from, 
to allow some legacy code I was helping rearchitect code to migrate off of 
hard-coded paths to things and manually loading configuration.  See 
this: http://j.mp/1dPIuGN

That being said, I've kind of regretted adding that feature ever since :-)

But I don't think you need anything so general or complex.

It's not clear from your post what you want to switch on to decide which 
implementation to provide.  You don't want to use @Named, but *something* 
has to choose which thing to inject.  So, where does the information live, 
which is used to decide that?  And does it change at runtime?

If it doesn't change at runtime, just give yourself a command-line argument 
or whatever equivalent makes sense for what you're doing (your class names 
above suggest some kind of test mode, but I'm guessing).  Have 
@ImplementedBy pointing to a mock implementation, and only install the 
module that binds the real implementation if that flag is not there (or is 
there, whatever you want).

If it's something more fancy, I don't think anyone can help you without 
knowing what information should be used to decide what to inject, and what 
part of the application has it.  If you know what that is, all you need to 
do is write a Provider that uses it.

-Tim

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to