if (application.getParentContext() == null) {
application.setApplicationContext(parent);
}
GrailsRuntimeConfigurator configurator = null;
if (parent.containsBean(GrailsRuntimeConfigurator.BEAN_ID)) {
// get configurator from parent application context
configurator = (GrailsRuntimeConfigurator)parent.getBean(GrailsRuntimeConfigurator.BEAN_ID);
}
else {
// get configurator from servlet context
configurator = determineGrailsRuntimeConfiguratorFromServletContext(application, servletContext, parent);
}
if (configurator == null) {
// no configurator, use default
configurator = new GrailsRuntimeConfigurator(application,parent);
if (parent.containsBean(GrailsPluginManager.BEAN_NAME)) {
GrailsPluginManager pluginManager = (GrailsPluginManager)parent.getBean(GrailsPluginManager.BEAN_NAME);
configurator.setPluginManager(pluginManager);
}
}
final GrailsPluginManager pluginManager = configurator.getPluginManager();
// return a context that obeys grails' settings
WebApplicationContext webContext = configurator.configure(servletContext);
pluginManager.setApplicationContext(webContext);
configureServletContextAttributes(servletContext, application, pluginManager, webContext);
LOG.info("[GrailsContextLoader] Grails application loaded.");
return webContext;