Install this plugin and you would be able to delegate methods from a containing class to its delegate member. A delegate member is the containing class'es field annotated with @Delegate
The priority of the method look up is as follows:
- Containing class's declared method
- Delegate's declared method
- Containing class's dynamic methods
- Delegate's dynamic method
Example:
class DomainService {
def add(Domain d) {
// ...
}
}
class ComponentService {
@Delegate
def domainService = new DomainService()
}
class ComponentController {
ComponentService componentService;
def save {
// invoking DomainService#add(...) directly from an instance of ComponentService
componentService.add(...);
}
}