Which version are you using? This will only work starting with 
4.0-beta5: 
https://github.com/google/guice/commit/4faa20e3081448792933834aedfe972add806292

On Thursday, June 11, 2015 at 2:10:56 PM UTC+2, Suma Shivaprasad wrote:
>
> Trying to inject a collection of providers which implement an interface but 
> consistently getting issues with injection as below
>
>
> No implementation for 
> java.util.Collection<com.google.inject.Provider<TypesChangeListener>> was 
> bound.
>
> [ERROR] at 
> com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:435)
> [ERROR] at 
> com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:154)
> [ERROR] at 
> com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106)
>
>
>
> Module
>
> ========
>
>  Multibinder<TypesChangeListener> typesChangeListenerBinder = 
> Multibinder.newSetBinder(binder(), TypesChangeListener.class);
>         
> typesChangeListenerBinder.addBinding().to(GraphBackedSearchIndexer.class);
>
>  // bind the MetadataService interface to an implementation
>  
> bind(MetadataService.class).to(DefaultMetadataService.class).asEagerSingleton();
>
>
>
> Injected class
>
> ==============
>
>
> @Inject
> DefaultMetadataService(final B b, final C c, final 
> Collection<Provider<TypesChangeListener>> typeChangeListeners)
>
>
>
> GraphBackedSearchIndexer implements TypesChangeListener
>
>
>
> I see that Multibinder<TypesChangeListener> typesChangeListenerBinder = 
> Multibinder.newSetBinder(binder(), TypesChangeListener.class);
>
>
> is actually resulting in Set<TypesChangeListener> rather than 
> Set<Provider<TypesChangeListener>> which is what I need? 
>
>
> The javadoc for MultiBinder - 
> http://google.github.io/guice/api-docs/latest/javadoc/index.html?com/google/inject/multibindings/Multibinder.html
>  says "Collection<Provider<T>> could also be injected" but does not provide 
> any examples.
>
>
> Please let me know how this can be achieved.
>
>
>
> Thanks
> Suma
>
>
>

-- 
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/04013f7b-9e77-4a8a-90c6-4697db7e29da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to