Pimp my Grails Bootstrap

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

  1.  
  2. import grails.util.GrailsUtil
  3. import org.codehaus.groovy.grails.commons.GrailsApplication
  4.  
  5. class BootStrap {
  6.  
  7. def init = { servletContext ->
  8. if(!envMapping[GrailsUtil.environment]){
  9. }
  10.  
  11. envMapping[GrailsUtil.environment]()
  12. }
  13.  
  14. def destroy = {
  15. }
  16.  
  17. def initTest = {
  18. ...
  19. }
  20.  
  21. def initDev = {
  22. ...
  23. }
  24.  
  25. def initProd = {
  26. ...
  27. }
  28.  
  29. def envMapping = [(GrailsApplication.ENV_TEST):initTest,
  30. (GrailsApplication.ENV_DEVELOPMENT):initDev,
  31. (GrailsApplication.ENV_PRODUCTION):initProd]
  32. }
  33.  

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

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