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 New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.0 RC1
    • Fix Version/s: General Backlog
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

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

      Code implementation to follow.

        Issue Links

          Activity

          Hide
          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
          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.

            People

            • Assignee:
              Arjen Poutsma
              Reporter:
              Alex Antonov
              Last updater:
              Trevor Marshall
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                4 years, 26 weeks, 6 days ago