Hi All,
By further debug information, I have found that below error is throwing.
Unable to create binding for java.util.Set< <package>
.WarningInfoClientPlugin>.
It was already configured on one or more child injectors or private modules
bound at
<package>.AbstractInjectModule.multibind(AbstractInjectModule.java:130)
(via modules: com.google.inject.util.Modules$OverrideModule ->
com.google.inject.util.Modules$OverrideModule ->
com.google.inject.util.Modules$CombinedModule -> <package> .Configuration
-> com.google.inject.multibindings.Multibinder$RealMultibinder)
If it was in a PrivateModule, did you forget to expose the binding?
Any idea about it, Implementation of class is at another module, do I need
to add another configuration or something like that?
Regards,
Dilanka
On Wed, Oct 3, 2018 at 5:29 PM Dilanka Muthukumarana <[email protected]>
wrote:
> Hi Again,
>
> I am using configuration as below:
>
> multibind(WarningInfoClientPlugin.class,
> EPedDoseValidationWarningPlugin.class);
>
> protected final <T> void multibind(final Class<T> classType, final
> Class<?>... implementations)
> {
> final Multibinder<T> pluginBinder = Multibinder.newSetBinder(binder(),
> classType);
>
> for (final Class<?> impl : implementations)
> {
> pluginBinder.addBinding().to((Class<T>)impl);
> }
> }
>
> Thanks and Regards,
> Dilanka
>
>
> On Wed, Oct 3, 2018 at 5:17 PM Dilanka Muthukumarana <[email protected]>
> wrote:
>
>> Hi All,
>>
>>
>> Currently I am working in Guice injection related development and
>> experiencing injection problem with multiBind with optional= true.
>>
>> In guice-4.0, I have seen skipping injection if it is optional.
>>
>> code location: MembersInjectorStore.java
>> Method:
>> /**
>>
>> * Returns the injectors for the specified injection points.
>> */
>> ImmutableList<SingleMemberInjector> getInjectors(
>> Set<InjectionPoint> injectionPoints, Errors errors) {
>> List<SingleMemberInjector> injectors = Lists.newArrayList();
>> for (InjectionPoint injectionPoint : injectionPoints) {
>> try {
>> Errors errorsForMember = injectionPoint.isOptional()
>> ? new Errors(injectionPoint)
>> : errors.withSource(injectionPoint);
>> SingleMemberInjector injector = injectionPoint.getMember() instanceof
>> Field
>> ? new SingleFieldInjector(this.injector, injectionPoint,
>> errorsForMember)
>> : new SingleMethodInjector(this.injector, injectionPoint,
>> errorsForMember);
>> injectors.add(injector);
>> } catch (ErrorsException ignoredForNow) {
>> // ignored for now
>> }
>> }
>> return ImmutableList.copyOf(injectors);
>> }
>>
>>
>> My code is like below:
>>
>> private Set<WarningInfoClientPlugin> warningInfoClientPlugins;
>>
>> @Inject(optional = true)
>> public void setWarningPlugins(final Set<WarningInfoClientPlugin>
>> warningInfoClientPlugins)
>> {
>> this.warningInfoClientPlugins = warningInfoClientPlugins;
>> }
>>
>>
>> Code is perfectly working *without* *optional = true* attribute.
>>
>> Appreciate your help on this. Thank you.
>>
>>
>> Regards,
>>
>> Dilanka
>>
>> --
>> 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 https://groups.google.com/group/google-guice.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/google-guice/ee4a5435-a317-497a-a044-4175f4c9340b%40googlegroups.com
>> <https://groups.google.com/d/msgid/google-guice/ee4a5435-a317-497a-a044-4175f4c9340b%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
>
> ~~~~~~~~
> Regards,
> Dilanka Muthukumarana
>
>
--
~~~~~~~~
Regards,
Dilanka Muthukumarana
--
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 https://groups.google.com/group/google-guice.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-guice/CANLbWWudjS7Q7oRxH1jJFq9DcqbTLFj3NGFoL_XVqu5xc4F7sA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.