protected void configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext wac) { 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 if (this.contextId != null) { wac.setId(this.contextId); } else { // Generate default id... wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + ObjectUtils.getDisplayString(getServletContext().getContextPath()) + '/' + getServletName()); } } wac.setServletContext(getServletContext()); wac.setServletConfig(getServletConfig()); wac.setNamespace(getNamespace()); wac.addApplicationListener(new SourceFilteringListener(wac, new ContextRefreshListener())); // 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(getServletContext(), getServletConfig()); } postProcessWebApplicationContext(wac); applyInitializers(wac); wac.refresh(); }
protected void configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext wac) { 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 if (this.contextId != null) { wac.setId(this.contextId); } else { // Generate default id... wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + ObjectUtils.getDisplayString(getServletContext().getContextPath()) + '/' + getServletName()); } } wac.setServletContext(getServletContext()); wac.setServletConfig(getServletConfig()); wac.setNamespace(getNamespace()); wac.addApplicationListener(new SourceFilteringListener(wac, new ContextRefreshListener())); // 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(getServletContext(), getServletConfig()); } postProcessWebApplicationContext(wac); applyInitializers(wac); wac.refresh(); }
@Override public synchronized void setNamespace(String namespace) { this.appContext.setNamespace(namespace); }
public static ApplicationContext loadContext(Application application, HttpServletRequest request) { // Logging 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; } public Application get()
wac.setParent(parent); wac.setServletContext(getServletContext()); wac.setNamespace(getNamespace()); if (getContextConfigLocation() != null) { wac.setConfigLocations(
wac.setParent(parent); wac.setServletContext(getServletContext()); wac.setNamespace(getNamespace()); if (getContextConfigLocation() != null) { wac.setConfigLocations(
wac.setParent(parent); wac.setServletContext(getServletContext()); wac.setNamespace(getNamespace()); if (getContextConfigLocation() != null) { wac.setConfigLocations(
protected void configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext wac) { 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 if (this.contextId != null) { wac.setId(this.contextId); } else { // Generate default id... wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + ObjectUtils.getDisplayString(getServletContext().getContextPath()) + '/' + getServletName()); } } wac.setServletContext(getServletContext()); wac.setServletConfig(getServletConfig()); wac.setNamespace(getNamespace()); wac.addApplicationListener(new SourceFilteringListener(wac, new ContextRefreshListener())); // 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(getServletContext(), getServletConfig()); } postProcessWebApplicationContext(wac); applyInitializers(wac); wac.refresh(); }