Skip to content

Add methods to register InterceptorBindings annotation for creating intercepted instance for proxies during CDI registration and discovery. #873

@TheEliteGentleman

Description

@TheEliteGentleman

There's no way, currently, to apply Microprofile's fault tolerance interceptors to proxies.

E.g, with Microprofile RestClient, when creating a REST client Service interface (annotated with @RegisterRestClient) and add any MP Fault Tolerance interceptor annotations on a method, e.g., @Retry, the application container will never trigger it. That's because the "proxy" attached to the service is never spotted as a CDI bean, to link it to the SPI FT interceptor.

There's the same discussion I've raised with the Microprofile WG when we implemented Langchain4J-CDI (discussion here: https://groups.google.com/g/microprofile/c/lto5IHWkN1A).

I thought of introducing the following methods:

  1. Add the following on BeanConfigurator interface: BeanConfigurator<T> addInterceptorBindings(Set<InterceptorBindings> interceptorBindings);.
  2. Add the following on Bean interface: public Set<Annotation> getInterceptorBindings();.

This will require that when interceptor bindings annotations exists, the bean can be added to InterceptionFactory and return an intercepted instance of the proxy, else return the proxy.

This way, any SPI can register their custom InterceptorBindings annotations by adding their InterceptorBindings annotation and it'll guarantee to be intercepted.

For context, some SPI implementations are package-private so hacking a solution isn't possible (e.g., Helidon FT).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions