You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Introduce proxy-based REST client similar to HttpInvokerProxyFactoryBean [SPR-12131] #16747
This ticket proposes a new component that will work similarly to HttpInvokerProxyFactoryBean and allows binding a java interface to a remote REST/JSON service. Annotations on the interface and its methods would define the mapping of method invocations to concrete HTTP requests to the REST service.
The component would be a proxy factory which is given the mapping (possibly via a class name) and returns proxies which pass method invocations to the remote REST service.
It's been a while now and there hasn't been any progress. Like I said back then, I have a running implementation which I'd happily adapt to Spring standards and conventions. Rossen, would you help me work on that?
Tests are flaky because they depend on recorded & replayed messages - I will have a look at how the other invokers are tested in Spring and work out a compatible solution. The *ProxyFactoryBeans I've seen extend UrlBasedRemoteAccessor - I need to understand the type hierarchy better; maybe the BaseRestInvokerProxyFactoryBean should extend HttpInvokerClientInterceptor, I'll need your help for sorting that out. Also, the returned objects seem to be instances of ProxyFactory instead of returning directly proxies - I'm unclear as to why and if that is necessary. Last not least, because of the dependency on MVC annotations, the REST exporter can't live in the web module but needs to move to the web-mvc module (or a separate module)
While I think this ticket is a worthwhile idea still for the time being I'm moving it into the 5.x backlog. It is more important to focus on completing the work on the reactive WebClient and then consider this feature against both the RestTemplate and the WebClient.
This is not on the critical path to 5.0 IMO because using the RestTemplate by comparison doesn't require that much code. Also there are alternatives even today. For example the Netflix Feign client is flexible enough to support different annotations and the Spring Cloud team have done that already. In fact I am wondering George Georgovassilis if you considered or would consider using Feign? If nothing else it reduces what you would have to write and maintain.
There are also a few things I noticed while looking at your spring-rest-invoker. If we are to support #15682 which we are still considering then I'm not sure that it would make sense to use a syntax with multiple @RequestBody annotations on a method as shown in the examples. It seems to me the same could be achieved with a Map of objects serialized to JSON. Even if you don't care about re-using interfaces between client and server, consistent use on both sides semantically still matters from an API perspective.
Activity
spring-projects-issues commentedon Jul 17, 2016
George Georgovassilis commented
It's been a while now and there hasn't been any progress. Like I said back then, I have a running implementation which I'd happily adapt to Spring standards and conventions. Rossen, would you help me work on that?
spring-projects-issues commentedon Jul 19, 2016
Rossen Stoyanchev commented
Thanks the ping George Georgovassilis. We have a few related tickets and clearly something needs to be done but we need to make up our minds. I will need a little more time to respond more coherently. In the mean time can elaborate on what work may be required to adapt https://github.com/ggeorgovassilis/spring-rest-invoker above and beyond code style and conventions?
spring-projects-issues commentedon Jul 21, 2016
George Georgovassilis commented
Tests are flaky because they depend on recorded & replayed messages - I will have a look at how the other invokers are tested in Spring and work out a compatible solution. The *ProxyFactoryBeans I've seen extend UrlBasedRemoteAccessor - I need to understand the type hierarchy better; maybe the BaseRestInvokerProxyFactoryBean should extend HttpInvokerClientInterceptor, I'll need your help for sorting that out. Also, the returned objects seem to be instances of ProxyFactory instead of returning directly proxies - I'm unclear as to why and if that is necessary. Last not least, because of the dependency on MVC annotations, the REST exporter can't live in the web module but needs to move to the web-mvc module (or a separate module)
spring-projects-issues commentedon Sep 26, 2016
Rossen Stoyanchev commented
While I think this ticket is a worthwhile idea still for the time being I'm moving it into the 5.x backlog. It is more important to focus on completing the work on the reactive
WebClientand then consider this feature against both theRestTemplateand theWebClient.This is not on the critical path to 5.0 IMO because using the RestTemplate by comparison doesn't require that much code. Also there are alternatives even today. For example the Netflix Feign client is flexible enough to support different annotations and the Spring Cloud team have done that already. In fact I am wondering George Georgovassilis if you considered or would consider using Feign? If nothing else it reduces what you would have to write and maintain.
There are also a few things I noticed while looking at your spring-rest-invoker. If we are to support #15682 which we are still considering then I'm not sure that it would make sense to use a syntax with multiple
@RequestBodyannotations on a method as shown in the examples. It seems to me the same could be achieved with a Map of objects serialized to JSON. Even if you don't care about re-using interfaces between client and server, consistent use on both sides semantically still matters from an API perspective.spring-projects-issues commentedon Jun 21, 2018
George Georgovassilis commented
Since I submitted the ticket, my implementation received a few community contributions and is now available on maven central: https://github.com/ggeorgovassilis/spring-rest-invoker
I still prefer it over the alternatives mentioned because of its fewer dependencies and tighter coupling to Spring semantics.
rstoyanchev commentedon May 20, 2022
Superseded by #28386