On Sun, Jan 8, 2012 at 11:24 AM, Thomas Broyer <[email protected]> wrote:
>
>
> On Sunday, January 8, 2012 7:08:21 AM UTC+1, Aladdin wrote:
>>
>> @Thomas I think you MultiBinder is what I need but I'm using GIN and
>> it's not supported :(
>>
>>
>> Any other suggestions ?
>
>
> Could possibly be as simple as (in your GinModule):
>
> @Provides Set<ServiceConsumer<?>>
> provideServiceConsumers(CustomerAccountsServiceConsumer accountConsumer,
> CustomerCreditCardsServiceConsumer creditCardConsumer) {
> return new HashSet(Array.asList(accountConsumer, creditCardConsumer));
> }
>
> The major (if not only) difference with MultiBinder is that all bindings
> have to be known and declared in the same GinModule (whereas MultiBinder
> can "incrementally" add to the Set from distinct modules).
>
To be exact, I don't think all the bindings have to be *declared* in the
same Gin module, but they do have to be *known*. IE., in the above
snippet, CustomerAccountsServiceConsumer
& CustomerCreditCardsServiceConsumer can be declared in any module, but
one module must have the @Provides Set<ServiceConsumer<?>> and know about
all the of them in order to provide it.
sam
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-guice/-/pEypSi01Q-0J.
>
> 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.
>
--
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.