List of usage examples for org.springframework.web.context ConfigurableWebApplicationContext APPLICATION_CONTEXT_ID_PREFIX
String APPLICATION_CONTEXT_ID_PREFIX
To view the source code for org.springframework.web.context ConfigurableWebApplicationContext APPLICATION_CONTEXT_ID_PREFIX.
Click Source Link
From source file:nz.co.senanque.vaadinsupport.application.SpringApplicationLoader.java
public static ApplicationContext loadContext(Application application, HttpServletRequest request) { // Logging//from w ww .j av a 2 s .c om log.info("loading application context for Vaadin application " + application.getClass().getSimpleName()); CURRENT_APPLICATION.set(application); // Find the application context associated with the servlet; it will be the parent ServletContext servletContext; try { // getServletContext() is a servlet AIP 3.0 method, so don't freak out if it's not there servletContext = (ServletContext) HttpServletRequest.class.getMethod("getServletContext") .invoke(request); } catch (Exception e) { servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext(); } WebApplicationContext parent = WebApplicationContextUtils.getWebApplicationContext(servletContext); // Create and configure a new application context for this Application instance ConfigurableWebApplicationContext context = new XmlWebApplicationContext(); context.setId( ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + servletContext.getContextPath() + "/" + application.getClass().getSimpleName() + "-" + UNIQUE_INDEX.incrementAndGet()); context.setParent(parent); context.setServletContext(servletContext); //context.setServletConfig(??); context.setNamespace(application.getClass().getSimpleName()); // Refresh context context.refresh(); CURRENT_APPLICATION.set(null); return context; }
From source file:com.dhcc.framework.web.context.DhccContextLoader.java
protected void configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext wac, ServletContext sc) {//from w w w . j a v a 2s . co m Log logger = LogFactory.getLog(DhccContextLoader.class); if (ObjectUtils.identityToString(wac).equals(wac.getId())) { // The application context id is still set to its original default value // -> assign a more useful id based on available information String idParam = sc.getInitParameter(CONTEXT_ID_PARAM); if (idParam != null) { wac.setId(idParam); } else { // Generate default id... if (sc.getMajorVersion() == 2 && sc.getMinorVersion() < 5) { // Servlet <= 2.4: resort to name specified in web.xml, if any. wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + ObjectUtils.getDisplayString(sc.getServletContextName())); } else { wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + ObjectUtils.getDisplayString(sc.getContextPath())); } } } wac.setServletContext(sc); String initParameter = sc.getInitParameter(CONFIG_LOCATION_PARAM); if (isMicrokernelStart(sc)) { initParameter = "classpath:codeTemplate/applicationSetupContext.xml"; logger.error("because cant't connect to db or setup flg is 0 so init application as Microkernel "); } else { logger.info("initParameter==" + initParameter); } if (initParameter != null) { wac.setConfigLocation(initParameter); } customizeContext(sc, wac); wac.refresh(); }
From source file:org.alfresco.repo.web.util.AbstractJettyComponent.java
protected WebApplicationContext createWebApplicationContext(ServletContext sc, ApplicationContext parent) { GenericWebApplicationContext wac = (GenericWebApplicationContext) BeanUtils .instantiateClass(GenericWebApplicationContext.class); // Assign the best possible id value. wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + contextPath); wac.setParent(parent);// www. j av a 2 s. c om wac.setServletContext(sc); wac.refresh(); return wac; }
From source file:org.springframework.web.context.ContextLoader.java
protected void configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext wac, ServletContext sc) {/* w w w. j a va 2 s .c o m*/ if (ObjectUtils.identityToString(wac).equals(wac.getId())) { // The application context id is still set to its original default value // -> assign a more useful id based on available information String idParam = sc.getInitParameter(CONTEXT_ID_PARAM); if (idParam != null) { wac.setId(idParam); } else { // Generate default id... wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + ObjectUtils.getDisplayString(sc.getContextPath())); } } wac.setServletContext(sc); String configLocationParam = sc.getInitParameter(CONFIG_LOCATION_PARAM); if (configLocationParam != null) { wac.setConfigLocation(configLocationParam); } // The wac environment's #initPropertySources will be called in any case when the context // is refreshed; do it eagerly here to ensure servlet property sources are in place for // use in any post-processing or initialization that occurs below prior to #refresh ConfigurableEnvironment env = wac.getEnvironment(); if (env instanceof ConfigurableWebEnvironment) { ((ConfigurableWebEnvironment) env).initPropertySources(sc, null); } customizeContext(sc, wac); wac.refresh(); }