Tuesday, September 17, 2013

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.
 
class BootStrap {
    // Reference to Grails application.
    def grailsApplication

    def init = { servletContext ->
        // Access Grails application properties.
        grailsApplication.serviceClasses.each {
            println it 
        } 
    }

    def destroy = {}
}

No comments:

Post a Comment