Guice: inject different implementation depending on who is getting it?
问题 I have two third-party classes, both of which take an implementation of an Authorizer interface. I need to inject each with a different implementation. If I do an @Provides , how can I implement it so that it provides the implementation required at run time? The provider has no idea who is asking for the injection. In theory I could use @Named , but I can't modify the code being injected. I want to do something like: bind(Authorizer.class).to(ImplA.class).for(SomeClass.class) bind(Authorizer