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/d80493bd-c44d-450d-81a1-3b34229aab7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.