Skip to content

Enable REST controller method parameter annotations on an interface [SPR-11055] #15682

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits 790d515, 1f5d0fa

30 votes, 37 watchers

Metadata

Metadata

Assignees

Labels

has: votes-jiraIssues migrated from JIRA with more than 10 votes at the time of importin: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions