I know that I can replace the Spring bean provided by Grails simply by defining my own bean with the same name. For example, if I want to replace the messageSourcebean provided by Grails
class MyMessageSource implements MessageSource {
}
Then add the following to resources.groovy
messageSource(MyMessageSource)
However, suppose I want to MyMessageSourcebeautify the implementation of this bean provided by Grails
class MyMessageSource implements MessageSource {
MessageSource messageSource
}
I can’t figure out how to do this resources.groovy. Obviously, I cannot do this:
messageSource(MyMessageSource) {
messageSource = ref('messageSource')
}
Because it looks like I'm defining a bean that depends on itself. I could, of course, give my bean a different name, for example.
myMessageSource(MyMessageSource) {
messageSource = ref('messageSource')
}
But then any class outside my control (for example, the plugin class) declaring a dependency on messageSourcewill be set to the bean provided by Grails, and not my decorator.