Description
In most use cases, CDI qualifiers are applied using annotations. However, it's possible in CDI extensions to apply qualifiers to beans without adding annotations. In the example below, there are no annotations on the bean but it is qualified with Readiness.
// @Observes AfterBeanDiscovery event
event.addBean()
.types(HealthCheck.class)
.qualifiers(new ReadinessAnnotation())
.scope(ApplicationScoped.class)
.produceWith(obj -> {
return new CustomHealthCheck();
});
If an implementation were using the ProcessBean event to detect this bean, then processBean.getAnnotated() would not contain annotations but processBean.getBean().getQualifiers() would include the readiness qualifier.
When reading the spec, I'm not certain if beans defined in this way must/may be included in the health check endpoints. This statement from the spec leads me to think it's optional.
Any enabled bean with a bean of type org.eclipse.microprofile.health.HealthCheck and @Liveness, @Readiness, or @Startup qualifier can be used as health check procedure.
However, other areas of the spec speak very directly about requiring one of the annotations.
A HealthCheck procedure with none of the above annotations is not an active procedure and should be ignored.
I'm not really sure where beans like the one above fit into the specification. Does the spec intend for these to be used or are they outside the scope of the specification? I appreciate any guidance the community can provide.
Description
In most use cases, CDI qualifiers are applied using annotations. However, it's possible in CDI extensions to apply qualifiers to beans without adding annotations. In the example below, there are no annotations on the bean but it is qualified with
Readiness.If an implementation were using the
ProcessBeanevent to detect this bean, thenprocessBean.getAnnotated()would not contain annotations butprocessBean.getBean().getQualifiers()would include the readiness qualifier.When reading the spec, I'm not certain if beans defined in this way must/may be included in the health check endpoints. This statement from the spec leads me to think it's optional.
However, other areas of the spec speak very directly about requiring one of the annotations.
I'm not really sure where beans like the one above fit into the specification. Does the spec intend for these to be used or are they outside the scope of the specification? I appreciate any guidance the community can provide.