- All Implemented Interfaces:
- ConfigurableRule<com.sun.codemodel.JCodeModel,com.sun.codemodel.JDefinedClass,ApiResourceMetadata>, Rule<com.sun.codemodel.JCodeModel,com.sun.codemodel.JDefinedClass,ApiResourceMetadata>
public class Spring4ControllerDecoratorRule
extends SpringControllerDecoratorRule
A code generation Rule that provides a Spring4 Controller based on a decorator pattern.
The goal is to generate code that does not have to be manually extended by the user.
A raml endpoint called /people for example implies two generated artefacts:
// 1. Controller Interface
interface PeopleController {
ResponseEntity getPeople();
}
// 2. A Decorator that implements the Controller Interface
// and delegates to another instance of a class implementing the very same controller interface.
@RestController
@RequestMapping("/people")
class PeopleControllerDecorator implements PeopleController {
@Autowired
PeopleController peopleControllerDelegate;
@RequestMapping(value="", method=RequestMethod.GET)
public ResponseEntity getPeople() {
return this.peopleControllerDelegate.getPeople();
}
}
Now all the user has to do is to implement a Spring-Bean called "PeopleControllerDelegate".
This way he can implement the endpoint without altering the generated code.
- Since:
- 0.4.1
- Author:
- armin.weisser, kurtpa