I'm using "multi binding" - look at the code snippet below:

public interface ICommand {
   void doSomething();
}

(module)

bind(ICommand.class).annotatedWith(Names.named("UserCommand")).to
(UserCommandConcrete.class);        bind(IICommand.class).annotatedWith
(Names.named("AdminCommand")).toAdminCommandConcrete.class);

then can get instance via:

ICommand iRun = injector.getInstance(
                Key.get(ICommand.class,
                Names.named("UserCommand)));

-------------------

But I need some extra parameters to UserCommandConcrete constructor
e.g.

class UserCommandConcrete implements ICommand {

  private final String userInfo;

   @Inject
   public UsetCommandConcrete(String userInfo) {
      this.userInfo = userInfo;
   }

 ........

}

In "single binding" I can accomplish that with factory and @Assisted
annotation.

But what about "multi binding" ? Is there any way ?


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