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.
Currently, the specification states:
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:
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.