Guice Merge Collection between AbstractModules

34 views
Skip to first unread message

Pablo perez

unread,
Apr 26, 2016, 7:04:06 AM4/26/16
to google-guice

I have a couple modules

 A extends AbstractModule

 B extends AbstractModule

Which are used to provide class C.

 class C {

    @Inject List<Components> components;
 }

That class C can use A, B or both to be instantiate with a specific information.

For now I have a provider on A module

 @Provider
 List<Components>

Of course I can only have one provider per context, so only A can have it so far. But I need on both because everyone generate his own Components.

I´ve been reading about Multibinders https://github.com/google/guice/wiki/Multibindings

But I would like to know before go for a guice extension, if the guice core provide a mechanism for what I want to do.

Regards.


Luke Sandberg

unread,
Apr 28, 2016, 1:09:58 PM4/28/16
to google-guice
Multibindings is what you want.  (imho it should just be part of the core)

--
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 google-guice...@googlegroups.com.
To post to this group, send email to google...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/11b91eb4-e823-4ee6-afb3-f2c25acfca5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages