Comments (9)
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.
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.
@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.
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.
See also #107
from microprofile-rest-client.
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.
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.
...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.
closed with PR #140
from microprofile-rest-client.
Related Issues (20)
- TCK Challenge: HasConversationScopeTest HOT 5
- Have string overloaded methods for uri/url methods HOT 3
- Allow ResponseExceptionMapper to swallow exceptions HOT 4
- MicroProfile Rest Client 3.0 Compatible Certification Request
- The 3.0 TCK Relies on old Jakarta/Java EE Servlet Specification HOT 2
- MicroProfile Rest Client 3.0 release on Maven Central? HOT 2
- MicroProfile Rest Client 2.0 Compatible Certification Request - Payara Community 5.2021.10 HOT 1
- Setting SSLContext for CDI injected clients HOT 3
- Clarification for behavior of Default ResponseExceptionMapper when method signature returns Result HOT 3
- Replace javax namespace usage with jakarta HOT 1
- Fault Tolerance support in builder created client HOT 4
- Clarification about closing the rest client HOT 2
- [question] Can I build a new implementation for microprofile-rest-client? HOT 3
- RestClientBuilderResolver does not work when the security manager is enabled
- Clarify What Exceptions Can Be Thrown When Closing A Client HOT 5
- ClientRequestFilter and ClientResponseFilter priority tests absent from MP Rest Client TCK HOT 1
- Align with Jakarta EE 10
- ConfigKeyForMultipleInterfacesTest uses the same WAR file name as ConfigKeyTest HOT 4
- Can we wrap all parameters including body parameter into a single object ? HOT 4
- No TCK coverage for exception mappers when subresource interface methods are called
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from microprofile-rest-client.