Petr,
The qualifiers attribute is named with an ‘s’ at the end, suggesting plural, and JavaDoc states that the value is a list of qualifiers, so it does cover allowing multiple qualifiers to be defined as in your
example,
@ContextServiceDefinition(name = "java:app/ContextBC", qualifiers = {MyContextQualifierB.class, MyContextQualifierC.class})
Given that you are also showing the following not commented out,
@Inject
@MyContextQualifierA
ContextService csA;
I assume you also have something like this,
@ContextServiceDefinition(name = "java:app/ContextA", qualifiers = MyContextQualifierA.class)
Regarding your commented out examples,
This one looks okay because you have a ContextServiceDefinition with
MyContextQualifierB
// @Inject
// @MyContextQualifierB
// ContextService csB;
This one will not work because it would require both A and B on the same ContextServiceDefinition, which you do not have, or if you did try to add a ContextServiceDefinition with that, it would be in conflict
with the others that already have A or B.
// @Inject
// @MyContextQualifierA
// @MyContextQualifierB
// ContextService csAB;
The following does not work either for the same reason.
// @Inject
// @MyContextQualifierA
// @MyContextQualifierB
// @MyContextQualifierC
// ContextService csABC;
It should be noted that all of the examples that do not work could be made to work by getting rid of the other conflicting ContextServiceDefinitions, but then that would cause some of your non-commented out
examples to become invalid.
From:
cu-dev <cu-dev-bounces@xxxxxxxxxxx> on behalf of Petr Aubrecht via cu-dev <cu-dev@xxxxxxxxxxx>
Date: Saturday, April 13, 2024 at 2:25 PM
To: cu developer discussions <cu-dev@xxxxxxxxxxx>
Cc: Petr Aubrecht <aubrecht@xxxxxxxxxxxx>
Subject: [EXTERNAL] [cu-dev] Qualifiers in *Definition annotations
Hello all, I have a dumb question. I'm working on the *Definition annotations and CDI integration (the qualifiers thing). And the question is about combinations
of qualifiers. It is not mentioned in javadoc and TCK doesn't test it. Should the
This Message Is From an External Sender
This message came from outside your organization.
Hello all,
I have a dumb question. I'm working on the *Definition annotations and CDI integration (the qualifiers thing).
And the question is about combinations of qualifiers. It is not mentioned in javadoc and TCK doesn't test it. Should the commented out examples work as well?
@Inject
ContextService csDefault;
@Inject
@MyContextQualifierA
ContextService csA;
// @Inject
// @MyContextQualifierB
// ContextService csB;
// @Inject
// @MyContextQualifierA
// @MyContextQualifierB
// ContextService csAB;
@Inject
@MyContextQualifierB
@MyContextQualifierC
ContextService csBC;
// @Inject
// @MyContextQualifierA
// @MyContextQualifierB
// @MyContextQualifierC
// ContextService csABC;
MyContextQualifier* are qualifiers. Their corresponding definitions look like
@ContextServiceDefinition(name = "java:app/ContextBC", qualifiers = {MyContextQualifierB.class, MyContextQualifierC.class})
Thank you for clarification.
Petr