As mentioned earlier, doing this is as simple as:

// In each module that has a service:
Multibinder<Service> multibinder = Multibinder.newSetBinder(binder(),
Service.class);
multibinder.addBinding().to(MyService.class);

// In one main module:
@Provides ServiceManager provideServiceManager(Set<Service> services) {
   return new ServiceManager(services);
}

// And in your app:
@Inject ServiceManager serviceManager;
void start() {
   serviceManager.startAsync().awaitHealthy();
}

sam

On Fri, Oct 3, 2014 at 6:40 PM, Martin Grajcar <[email protected]> wrote:

> On Fri, Oct 3, 2014 at 8:26 AM, Kevin Burton <[email protected]> wrote:
>
>> Hm.. only that won't work... I guess this is due to type erasure? fun!
>>
>> com.google.inject.CreationException: Unable to create injector, see the
>> following errors:
>>
>> 1) T cannot be used as a key; It is not fully specified.
>>
>
>
> If @Provides T getValue()  could work, then it'd provide everything, or
> wouldn't it?
>
> I might be completely wrong, but why don't you use
> com.google.common.util.concurrent?
>
> - wrap every service as a subclass of AbstractService (just 2 simple
> methods)
> - write a class requiring all of them
> - and passing them to a ServiceManager
> - call ServiceManager#startAsync to start them all
> - call ServiceManager#stopAsync to stop them all
> - do whatever else it offers
>
>  --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/google-guice.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-guice/CAGsWfGjHr%3Da6R6toOGF-w_%3DNeUZvOkm-jUJXzSyBO80xVyxdXQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/google-guice/CAGsWfGjHr%3Da6R6toOGF-w_%3DNeUZvOkm-jUJXzSyBO80xVyxdXQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/CAJEBNUfnznLxCbz-UY6hG4TXJ0fDC7imyXs178eUHLA5SFbkRw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to