List of usage examples for org.springframework.web.context ConfigurableWebApplicationContext setEnvironment
void setEnvironment(ConfigurableEnvironment environment);
From source file:com.helpinput.spring.servlet.mvc.EnhanceDispachServlet.java
@Override protected WebApplicationContext createWebApplicationContext(ApplicationContext parent) { ContextHolder.beanRegistIntercpterHolder.register(new UrlInterceptorBeanRegistInterceptor()); Class<?> contextClass = getContextClass(); if (logger.isDebugEnabled()) { logger.debug("Servlet with name '" + getServletName() + "' will try to create custom WebApplicationContext context of class '" + contextClass.getName() + "'" + ", using parent context [" + parent + "]"); }//from ww w . ja v a2s .co m if (!ConfigurableWebApplicationContext.class.isAssignableFrom(contextClass)) { throw new ApplicationContextException("Fatal initialization error in servlet with name '" + getServletName() + "': custom WebApplicationContext class [" + contextClass.getName() + "] is not of type ConfigurableWebApplicationContext"); } ConfigurableWebApplicationContext wac; if (parent instanceof ConfigurableWebApplicationContext) wac = (ConfigurableWebApplicationContext) parent; else { wac = (ConfigurableWebApplicationContext) BeanUtils.instantiateClass(contextClass); wac.setEnvironment(getEnvironment()); wac.setParent(parent); wac.setConfigLocation(getContextConfigLocation()); configureAndRefreshWebApplicationContext(wac); } return wac; }