I think you've got one problem and two possible solutions, each to
different problems.  So once you figure out what problem you have you
can find the solution.

Problem 1:
Multiple modules have Services.  One has a BillingService, and the
other has a HibernateService.  One piece of code would like to @Inject
Set<Service> and get both of them.

Problem 2:
Multiple modules have Services.  One has a BillingService, and the
other has a HibernateService.  One piece of code would like to @Inject
Set<Service> and get just one of them (the "right" one).  Another
piece of code would like to  @Inject Set<Service> and get just one of
them (the other "right" one).

If you have Problem 1: it works for me just fine without passing the
multibinder instance around; perhaps it has to do with private
modules, as you point out.

If you have Problem 2: this is robot legs.  You can see from the
problem statement that trying to figure out which one is "right" for
each module is a problem.  If you're trying to use private modules to
scope it and that's not working for you, then you might try an
annotation.  You can have a multibibder for @Named("left") and one for
@Named("right"), using the annotation arg to newSetbinder.  Then, your
code does @Inject @Named("right") and will get the "right" one.  For
better encapsulation, define your own annotation instead of using
@Named.  Now your Set is scoped to the module that knows about that
annotation type; sadly, it's a public interface, but at least you can
see by imports (or perhaps even classpaths) who is using it.

Leigh.


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