java - Injecting Collection of Classes with Guice -
i'm trying inject things google guice 2.0 , have following structure:
fooaction implements action baraction implements action
i have actionlibrary following constructor:
actionlibrary (list<action> theactions)
when request instance of actionlibrary guice, guice identify both of registered action classes (fooaction, baraction) , pass them constructor. motivation here being when add third action bazaction, simple registering in module , automatically added list in constructor.
is possible?
what want multibindings. specifically, want bind set<action>
(not list
, set
want anyway) this:
multibinder<action> actionbinder = multibinder.newsetbinder(binder(), action.class); actionbinder.addbinding().to(fooaction.class); actionbinder.addbinding().to(baraction.class);
then can @inject
set<action>
anywhere.
Comments
Post a Comment