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

Enable REST controller method parameter annotations on an interface

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 4.3.3
    • Fix Version/s: 5.1 RC1
    • Component/s: Web
    • Labels:
    • Last commented by a User:
      true

      Description

      Please, enable inheritance of controller related annotations from implemented interfaces.

      I would like to share rest service interface between client and server. This way I could provide a really convenient mechanism - client-proxy, like the one RestEasy provides.

      Shared interface:

      @RequestMapping("/random")
      public interface RandomDataController {
      
      	@RequestMapping(value = "/{type}", method = RequestMethod.GET)
      	@ResponseBody
      	RandomData getRandomData(
      			@PathVariable(value = "type") RandomDataType type, @RequestParam(value = "size", required = false, defaultValue = "10") int size);
      }
      

      Server implementation:

      @Controller
      public class RandomDataImpl implements RandomDataController {
      
      	@Autowired
      	private RandomGenerator randomGenerator;
      
      	@Override
      	public RandomData getPathParamRandomData(RandomDataType type, int size) {
      		return randomGenerator.generateRandomData(type, size);
      	}
      }
      

      Client code:

      // ...
      RandomDataController randomDataController = SpringMvcProxyFactory.create(RandomDataController.class, "http://localhost:8080");
      RandomData rd = randomDataController.getRandomData(RandomDataType.ALPHA, 100);
      // ...
      

      At the moment I cannot write SpringMvcProxyFactory because parameter annotations from interface RandomDataController are not inherited by RandomDataControllerImpl.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              mendlik PaweĊ‚ Mendelski
              Last updater:
              Spring Issues
              Votes:
              30 Vote for this issue
              Watchers:
              38 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                2 years, 2 weeks ago