Hi,

I tested some scenarios when using multiple qualifiers for test-cases
in MyFaces CODI and stumbled upon the following scenario, which is not
totally clear to me.

Image you have the following producer methods:

    @Produces
    @Qualifier2
    @ApplicationScoped
    public ProducerBean createWithQualifier2()
    {
        return new ProducerBean();
    }

    @Produces
    @Qualifier1
    @Qualifier2
    @ApplicationScoped
    public ProducerBean createWithQualifier1And2()
    {
        return new ProducerBean();
    }


and you want to inject the instances produced by these producers. Now
you can use @Inject @Qualifier1 or @Inject @Qualifier1 @Qualifier2,
but when using @Inject @Qualifier2 you will get an exception, because
the injection point is ambiguous (both producers provide @Qualifier2).

However I was wondering if this is really unresolvable ambiguous,
because if you think about it, it would make sence to take the
producer createWithQualifier2() in this scenario (because the other
one provides additional qualifiers).

I also took a look in the CDI spec about this, but could only find the
following from section 2.3.4: "A bean may only be injected to an
injection point if it has all the qualifiers of the injection point."
Of course this applies to both producers and thus, yes, it's kinda
ambiguous.

WDYT?

Regards,
Jakob

-- 
Jakob Korherr

blog: http://www.jakobk.com
twitter: http://twitter.com/jakobkorherr
work: http://www.irian.at

Reply via email to