eclipse / microprofile-rest-client

MicroProfile Rest Client
Apache License 2.0
141 stars 71 forks source link

Clarify specification text for CDI support #381

Closed manovotn closed 3 months ago

manovotn commented 3 months ago

Currently, the specification states:

Rest Client interfaces may be injected as CDI beans. The runtime must create a CDI bean for each interface annotated with RegisterRestClient. The bean created will include a qualifier @RestClient to differentiate the use as an API call against any other beans registered of the same type. Based on the rules of how CDI resolves bean, you are only required to use the qualifier if you have multiple beans of the same type.

However, the last part is not how CDI works, the @RestClient annotation is not optional. We should either curate the sentence or remove it. Below is an explanation of why it's not true with links to the CDI specification. I'll send a PR shortly.

Every bean has a set of types and a set of qualifiers and because all rest client beans always contain @RestClient, they will not contain the built-in @Default qualifier.

Now, consider following injection point:

@Inject
Foo foo;

To satisfy this injection point, you need a bean of type Foo but also with@Default qualifier (2.2.8. The default qualifier at injection points). As shown above, this is a condition no rest client bean satisfies.

FTR, this originally came up in a Quarkus issue where there was a discussion about possibly omitting the qualifier.