Search

Dark theme | Light theme

January 14, 2010

Grails Goodness: Access Grails Application in BootStrap

Accessing the Grails application object in BootStrap.groovy is easy. We only have to define a variable named grailsApplication and Spring's name based injection takes care of everything.

 
1
2
3
4
5
6
7
8
9
10
11
12
class BootStrap {
    // Reference to Grails application.
    def grailsApplication
 
    def init = { servletContext ->
        // Access Grails application properties.
        grailsApplication.serviceClasses.each {
            println it
        }
    }
 
    def destroy = {}
}