Pimp my Grails Bootstrap

If you want to depend data loaded in bootstrap from environment that application is currently running in, try this solution:

 
import grails.util.GrailsUtil
import org.codehaus.groovy.grails.commons.GrailsApplication
 
class BootStrap {
 
    def init = { servletContext ->
        if(!envMapping[GrailsUtil.environment]){
            return
        }
 
        envMapping[GrailsUtil.environment]()
    }
 
    def destroy = {
    }
 
    def initTest = {
    ...
    }
 
    def initDev = {
    ...
    }
 
    def initProd = {
    ...
    }
 
    def envMapping = [(GrailsApplication.ENV_TEST):initTest,
                      (GrailsApplication.ENV_DEVELOPMENT):initDev,
                      (GrailsApplication.ENV_PRODUCTION):initProd]
}
 

Variable envMapping is on the end BootStrap class becouse in other case values in map were set as null (???).

No Comments yet »

RSS feed for comments on this post.

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*

Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds. Valid XHTML and CSS.