Closed
Description
Paweł Mendelski opened SPR-11055 and commented
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
.
Affects: 4.3.3
Issue Links:
- @RequestBody annotation in interface is ignored [SPR-15714] #20270
@RequestBody
annotation in interface is ignored ("is duplicated by") - Inconsistent interpretation of parameter annotations in interface-based handler methods [SPR-14021] #18593 Inconsistent interpretation of parameter annotations in interface-based handler methods ("is duplicated by")
- mvc Parameter annotations are not inherited [SPR-14526] #19095 mvc Parameter annotations are not inherited ("is duplicated by")
- Spring Mvc Annotations in argument of a method (like @Path) annotated with @RequestMapping are not supported when you create a @RestController via an Interface [SPR-14805] #19371 Spring Mvc Annotations in argument of a method (like
@Path
) annotated with@RequestMapping
are not supported when you create a@RestController
via an Interface ("is duplicated by") - RequestHeader annotation does not work if it's put on an interface [SPR-15023] #19590 RequestHeader annotation does not work if it's put on an interface ("is duplicated by")
- Consider reusing @RequestMapping annotations as an interface for HTTP clients [SPR-12213] #16827 Consider reusing
@RequestMapping
annotations as an interface for HTTP clients ("is duplicated by") - Allow controller parameter annotations (@RequestBody, @PathVariable...) to be defined on interfaces or parent classes [SPR-15046] #19612 Allow controller parameter annotations (
@RequestBody
,@PathVariable
...) to be defined on interfaces or parent classes ("is duplicated by") - Supports annotating parameter annotations like @PathVariable on interface method [SPR-16110] #20658 Supports annotating parameter annotations like
@PathVariable
on interface method ("is duplicated by") - Aliases in parameter annotations on a controller interface are not evaluated [SPR-17460] #21992 Aliases in parameter annotations on a controller interface are not evaluated
- MethodParameter.isOptional() fails with ArrayIndexOutOfBoundsException [SPR-17629] #22160 MethodParameter.isOptional() fails with ArrayIndexOutOfBoundsException
- Introduce proxy-based REST client similar to HttpInvokerProxyFactoryBean [SPR-12131] #16747 Introduce proxy-based REST client similar to HttpInvokerProxyFactoryBean
- getMappingForMethod failed when implement a interface method(with @RequestMapping) in super class [SPR-17223] #21756 getMappingForMethod failed when implement a interface method(with
@RequestMapping
) in super class - Annotations on generic interface methods not found by AnnotationUtils [SPR-16060] #20609 Annotations on generic interface methods not found by AnnotationUtils
- Subclass-resolved generic return type declarations for handler methods [SPR-16877] #21416 Subclass-resolved generic return type declarations for handler methods
- @DateTimeFormat annotations are necessary both on field and constructor parameter in the immutable form class [SPR-16840] #21380
@DateTimeFormat
annotations are necessary both on field and constructor parameter in the immutable form class
Referenced from: commits 790d515, 1f5d0fa
30 votes, 37 watchers