public static GrailsApplication lookupApplication ( ServletContext servletContext ) { if ( servletContext == null ) { return null ; } GrailsApplication grailsApplication = ( GrailsApplication ) servletContext . getAttribute ( ApplicationAttributes . APPLICATION ) ; if ( grailsApplication != null ) { return grailsApplication ; } final WebApplicationContext context = WebApplicationContextUtils . getWebApplicationContext ( servletContext ) ; if ( context == null || ! context . containsBean ( GrailsApplication . APPLICATION_ID ) ) { return null ; } return context . getBean ( GrailsApplication . APPLICATION_ID , GrailsApplication . class ) ; }
Looks up a GrailsApplication instance from the ServletContext .