Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce proxy-based REST client similar to HttpInvokerProxyFactoryBean [SPR-12131] #16747

Open
spring-issuemaster opened this issue Aug 28, 2014 · 5 comments

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Aug 28, 2014

George Georgovassilis opened SPR-12131 and commented

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.

For a possible implementation see https://github.com/ggeorgovassilis/spring-rest-invoker


Affects: 4.0.6, 4.3.3

Reference URL: https://groups.google.com/forum/#!topic/spring-framework-contrib/HTja1bE1TWY

Issue Links:

  • #10929 Spring MVC REST: Provide interface definition model for generating HTTP client interface proxies wrapping RestTemplates ("duplicates")
  • #15682 Enable REST controller method parameter annotations on an interface
  • #22154 @RequestMapping without @Controller registered as handler
  • #16827 Consider reusing @RequestMapping annotations as an interface for HTTP clients
  • #16712 Read RestTemplate Accept header from entity annotation

4 votes, 9 watchers

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented 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-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented 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-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented 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-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented 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 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.

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented 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.

 

 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.