List of usage examples for org.springframework.web.context WebApplicationContext getParent
@Nullable ApplicationContext getParent();
From source file:org.sakaiproject.component.impl.ContextLoader.java
/** * Initialize the local ApplicationContext, link it to the shared context, and load shared definitions into the shared context. * //w w w .j a v a 2s .c o m * @param servletContext * current servlet context * @return the new WebApplicationContext * @throws BeansException * if the context couldn't be initialized */ public WebApplicationContext initWebApplicationContext(ServletContext servletContext) throws BeansException { WebApplicationContext rv = super.initWebApplicationContext(servletContext); // if we have a parent and any shared bean definitions, load them into the parent ConfigurableApplicationContext parent = (ConfigurableApplicationContext) rv.getParent(); if (parent != null) { String sharedConfig = servletContext.getInitParameter(SHARED_LOCATION_PARAM); if (sharedConfig != null) { String[] locations = StringUtils.tokenizeToStringArray(sharedConfig, ConfigurableWebApplicationContext.CONFIG_LOCATION_DELIMITERS); if (locations != null) { XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader( (BeanDefinitionRegistry) parent.getBeanFactory()); for (int i = 0; i < locations.length; i++) { try { reader.loadBeanDefinitions(rv.getResources(locations[i])); } catch (IOException e) { M_log.warn("exception loading into parent: " + e); } } } } } return rv; }
From source file:org.codehaus.groovy.grails.web.context.GrailsConfigUtils.java
public static void configureServletContextAttributes(ServletContext servletContext, GrailsApplication application, GrailsPluginManager pluginManager, WebApplicationContext webContext) { servletContext.setAttribute(ApplicationAttributes.PLUGIN_MANAGER, pluginManager); // use config file locations if available servletContext.setAttribute(ApplicationAttributes.PARENT_APPLICATION_CONTEXT, webContext.getParent()); servletContext.setAttribute(GrailsApplication.APPLICATION_ID, application); servletContext.setAttribute(ApplicationAttributes.APPLICATION_CONTEXT, webContext); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webContext); }
From source file:org.codehaus.groovy.grails.web.context.GrailsContextLoader.java
@Override public void closeWebApplicationContext(ServletContext servletContext) { // clean up in war mode, in run-app these references may be needed again if (application == null || !application.isWarDeployed()) { return;//from w ww . j a v a 2 s . com } WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext); ConfigurableApplicationContext parent = ctx != null ? (ConfigurableApplicationContext) ctx.getParent() : null; try { super.closeWebApplicationContext(servletContext); } finally { ShutdownOperations.runOperations(); } if (parent != null) { LOG.info("Destroying Spring parent WebApplicationContext " + parent.getDisplayName()); parent.close(); } try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); } catch (AccessControlException e) { // container doesn't allow, probably related to WAR deployment on AppEngine. proceed. } application = null; }