I need to get the messageSource
in a class in src\groovy
. This class is used in UrlMappings.groovy
, and at the stage I'm using this class the application is not completely started yet.
Currently I'm using the following and it works:
MessageSource messageSource = ApplicationHolder.application.mainContext.getBean('messageSource')
String message = messageSource.getMessage("code", null, "default", locale)
But the ApplicationHolder
is deprecated, is there a way to achieve the same goal without using ApplicationHolder
?
//I'm using Grails 2.0.1