Open Azquelt opened 2 years ago
I think this is what we need to do:
In the CDI extension, have a @Observes @WithAnnotations(RegisterRestClient.class) ProcessAnnotatedType<?>
method which will be called for each class annotated with RegiterRestClient
. Build a collection of all of the rest client interfaces. Do not veto the type (it's an interface, so it shouldn't be treated as a bean by CDI anyway, and we want to give other extensions the chance to modify it).
In the CDI extension, have a @Observes AfterBeanDiscovery
method which will be called once after all the beans have been discovered. For each rest client interface:
AnnotatedType
.
AnnotatedType
, if it's still there, after all extensions have had the chance to modify itAnnotatedType
to check for CDI interceptor bindings (you can either extract this information now, or store the AnnotatedType
in your bean class and extract it laterSide note: although we should use AnnotatedType
for the interceptor bindings, we should still use reflection to find the rest client annotations, since rest client can also be used without CDI and we want that to be consistent.
Currently, MP Rest Client looks for interceptor bindings on the rest client interface using reflection in order to call interceptors annotated with
@AroundInvoke
when methods on the rest client bean are called.However, CDI is required to use it's AnnotatedType information to find interceptor bindings, not reflection (so that CDI Extensions have an opportunity to add or modify them).
MP Rest Client should do the same so that interceptor bindings work consistently between rest client beans and other CDI beans.
This is the cause of the additional code we currently have in MP Rest Client to handle Fault Tolerance interceptors.