Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-6261

Spring MVC REST: Provide interface definition model for generating HTTP client interface proxies wrapping RestTemplates

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 3.0 RC1
    • Fix Version/s: None
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      Provide interface definition model for generating HTTP client interface proxies wrapping RestTemplates.

      Code implementation to follow.

        Issue Links

          Activity

          Hide
          aantono Alex Antonov added a comment -

          As an example of what an interface would look like:

          public interface ProtobufHotelSearchService {
              @ServiceRequest(name="hotel.id", method= HttpInvocationHandler.RequestMethod.GET, pattern = "/${id}")
              public HotelProtos.Hotel findHotelById(@ParamName("id") Long id);
           
              @ServiceRequest(name="hotel.search", method= HttpInvocationHandler.RequestMethod.GET)
              public HotelProtos.HotelList findHotels(@ParamName("search") String search,
                                                      @ParamName("page") int page,
                                                      @ParamName("size") int size);
           
              @ServiceRequest(name="hotel.update")
              public void updateHotels(HotelProtos.Hotel h);
          }

          @ServiceRequest annotation would indicate to the invocation handler what HTTP call you are going to make.
          @ParamName is similar to @RequestParam & @PathVariable from MVC

          Those then get processed by the invocation handler to determine what the URL should look like, what HTTP method (GET, PUT, etc) should be executed, etc... After all that is figured out, a delegate call to RestTemplate can be made to actually process the request.

          Show
          aantono Alex Antonov added a comment - As an example of what an interface would look like: public interface ProtobufHotelSearchService { @ServiceRequest(name="hotel.id", method= HttpInvocationHandler.RequestMethod.GET, pattern = "/${id}") public HotelProtos.Hotel findHotelById(@ParamName("id") Long id);   @ServiceRequest(name="hotel.search", method= HttpInvocationHandler.RequestMethod.GET) public HotelProtos.HotelList findHotels(@ParamName("search") String search, @ParamName("page") int page, @ParamName("size") int size);   @ServiceRequest(name="hotel.update") public void updateHotels(HotelProtos.Hotel h); } @ServiceRequest annotation would indicate to the invocation handler what HTTP call you are going to make. @ParamName is similar to @RequestParam & @PathVariable from MVC Those then get processed by the invocation handler to determine what the URL should look like, what HTTP method (GET, PUT, etc) should be executed, etc... After all that is figured out, a delegate call to RestTemplate can be made to actually process the request.
          Hide
          mdeinum Marten Deinum added a comment -

          I guess this is what Netflix Feign already provides on the plain Spring MVC annotations.

          Show
          mdeinum Marten Deinum added a comment - I guess this is what Netflix Feign already provides on the plain Spring MVC annotations.
          Hide
          rstoya05-aop Rossen Stoyanchev added a comment -

          Yes indeed it is the same although a much older ticket. I will resolve it as superseded by the likes of SPR-12213 and SPR-12131 that are currently under consideration.

          Show
          rstoya05-aop Rossen Stoyanchev added a comment - Yes indeed it is the same although a much older ticket. I will resolve it as superseded by the likes of SPR-12213 and SPR-12131 that are currently under consideration.

            People

            • Assignee:
              rstoya05-aop Rossen Stoyanchev
              Reporter:
              aantono Alex Antonov
              Last updater:
              Rossen Stoyanchev
            • Votes:
              3 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                3 days ago