Coder Social home page Coder Social logo

Comments (9)

NottyCode avatar NottyCode commented on August 17, 2024 3

I think we need to get this done soon. Not being able to use the REST client with fault tolerance means you have to write extra boiler plate code to do fault tolerance for a REST client.

from microprofile-rest-client.

johnament avatar johnament commented on August 17, 2024

John's specific use case: adding fault tolerance annotations to the interfaces defined by a user.

This can come after 1.0, since you can wrap existing FT annotations in regular CDI beans that delegate to the interface.

from microprofile-rest-client.

johnament avatar johnament commented on August 17, 2024

@NottyCode I almost wonder if we need to get @antoinesd to weigh in on this. For one, the interface itself is not a CDI bean. However, are you expecting the fault tolerance annotations to work, even if you manually build the client?

from microprofile-rest-client.

mkouba avatar mkouba commented on August 17, 2024

I would also expect the FT annotations to work - it looks like a perfect fit. The problem is that neither CDI nor Interceptors spec define clearly whether and how this should be supported (currently only CDI beans and EE components are required to support interception). In theory, we could use BeanManager.resolveInterceptors() to obtain the interceptor beans, then instantiate interceptors using BeanManager.getReference() and simulate interceptor chain manually (e.g. inside java.lang.reflect.InvocationHandler). But this solution would not have support in specs (so it wouldn't be portable) and also there might be some problematic corner cases.

from microprofile-rest-client.

pilhuhn avatar pilhuhn commented on August 17, 2024

See also #107

from microprofile-rest-client.

mkouba avatar mkouba commented on August 17, 2024

For the record: @AroundInvoke interceptors are already implemented in Thorntail/SmallRye. See also http://docs.wildfly-swarm.io/2.1.0.Final/#_cdi_interceptors_support and https://github.com/smallrye/smallrye-rest-client/blob/master/testsuite/basic/src/test/java/io/smallrye/restclient/tests/ft/FaultToleranceTest.java.

from microprofile-rest-client.

OndroMih avatar OndroMih commented on August 17, 2024

Does it make sense to specify that all annotations on the REST client interface's class or methods, which are also interceptor bindings, are copied to the proxy CDI bean that's injected? This would apply them to the CDI bean and trigger interceptors as if the annotations were added to the virtual CDI bean.

It would be even better if the CDI spec covered this and specified that interceptor bindings are applied also if the annotations are defined on the interface that a CDI bean implements. But until then we can specify it in the MP REST Client spec.

from microprofile-rest-client.

mkouba avatar mkouba commented on August 17, 2024

...are copied to the proxy CDI bean that's injected?

Hm, what does that mean? There's no bean class for a MP Rest interface so you cannot just "copy" the interceptor bindings.

Also lifecycle interceptors (@PostConstruct, etc.) probably do not make much sense here. So we should be clear that only business method interceptors are partially supported (@AroundInvoke).

I would use something like:
If CDI is enabled, it is possible to associate business method interceptors with Rest Client proxy methods by using interceptor bindings.

Plus we should add some warning that the Interceptors spec works with the assumption that a target class always exists which is not the case here. So it might happen that some interceptors are not designed to work correctly with MP Rest proxies.

from microprofile-rest-client.

andymc12 avatar andymc12 commented on August 17, 2024

closed with PR #140

from microprofile-rest-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.