Search in sources :

Example 1 with ConfigurableWebEnvironment

use of org.springframework.web.context.ConfigurableWebEnvironment in project grails-core by grails.

the class GrailsWebApplicationContext method getEnvironment.

@Override
public ConfigurableWebEnvironment getEnvironment() {
    ConfigurableEnvironment env = super.getEnvironment();
    Assert.isInstanceOf(ConfigurableWebEnvironment.class, env, "ConfigurableWebApplication environment must be of type ConfigurableWebEnvironment");
    return (ConfigurableWebEnvironment) env;
}
Also used : ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) ConfigurableWebEnvironment(org.springframework.web.context.ConfigurableWebEnvironment)

Example 2 with ConfigurableWebEnvironment

use of org.springframework.web.context.ConfigurableWebEnvironment in project spring-framework by spring-projects.

the class FrameworkServlet method configureAndRefreshWebApplicationContext.

protected void configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext wac) {
    if (ObjectUtils.identityToString(wac).equals(wac.getId())) {
        // -> 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();
}
Also used : ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) ConfigurableWebEnvironment(org.springframework.web.context.ConfigurableWebEnvironment) SourceFilteringListener(org.springframework.context.event.SourceFilteringListener)

Aggregations

ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)2 ConfigurableWebEnvironment (org.springframework.web.context.ConfigurableWebEnvironment)2 SourceFilteringListener (org.springframework.context.event.SourceFilteringListener)1