Browse Source

Introduce ConfigurableWebEnvironment

Changes introduced in Spring 3.1 for Environment support inadvertently
established a cyclic dependency between the
org.springframework.web.context and
org.springframework.web.context.support packages, specifically through
web.context.ContextLoader's invocation of
web.context.support.WebApplicationContextUtils#initServletPropertySources.

This commit introduces ConfigurableWebEnvironment to break this cyclic
dependency. All web.context.ConfigurableWebApplicationContext types now
return web.context.ConfigurableWebEnvironment from their #getEnvironment
methods; web.context.support.StandardServletEnvironment now implements
ConfigurableWebEnvironment and makes the call to
web.context.support.WebApplicationContextUtils#initServletPropertySources
within its implementation of #initPropertySources. This means that
web.context.ContextLoader now invokes
web.context.ConfigurableWebEnvironment#initPropertySources instead of
web.context.support.WebApplicationContextUtils#initServletPropertySources
and thus the cycle is broken.

Issue: SPR-9440
Backport-Issue: SPR-9439
Backport-Commit: 2a2b6eef91
3.1.x
Chris Beams 14 years ago
parent
commit
1eb50297ad
  1. 28
      org.springframework.integration-tests/src/test/java/org/springframework/core/env/EnvironmentIntegrationTests.java
  2. 6
      org.springframework.web.servlet/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java
  3. 7
      org.springframework.web/src/main/java/org/springframework/web/context/ConfigurableWebApplicationContext.java
  4. 46
      org.springframework.web/src/main/java/org/springframework/web/context/ConfigurableWebEnvironment.java
  5. 18
      org.springframework.web/src/main/java/org/springframework/web/context/ContextLoader.java
  6. 16
      org.springframework.web/src/main/java/org/springframework/web/context/support/AbstractRefreshableWebApplicationContext.java
  7. 16
      org.springframework.web/src/main/java/org/springframework/web/context/support/GenericWebApplicationContext.java
  8. 17
      org.springframework.web/src/main/java/org/springframework/web/context/support/StandardServletEnvironment.java
  9. 13
      org.springframework.web/src/main/java/org/springframework/web/context/support/StaticWebApplicationContext.java

28
org.springframework.integration-tests/src/test/java/org/springframework/core/env/EnvironmentIntegrationTests.java vendored

@ -99,6 +99,7 @@ public class EnvironmentIntegrationTests {
private ConfigurableEnvironment prodEnv; private ConfigurableEnvironment prodEnv;
private ConfigurableEnvironment devEnv; private ConfigurableEnvironment devEnv;
private ConfigurableEnvironment prodWebEnv;
/** /**
* Constants used both locally and in scan* sub-packages * Constants used both locally and in scan* sub-packages
@ -125,6 +126,9 @@ public class EnvironmentIntegrationTests {
devEnv = new StandardEnvironment(); devEnv = new StandardEnvironment();
devEnv.setActiveProfiles(DEV_ENV_NAME); devEnv.setActiveProfiles(DEV_ENV_NAME);
prodWebEnv = new StandardServletEnvironment();
prodWebEnv.setActiveProfiles(PROD_ENV_NAME);
} }
@Test @Test
@ -348,24 +352,24 @@ public class EnvironmentIntegrationTests {
assertHasStandardServletEnvironment(ctx); assertHasStandardServletEnvironment(ctx);
ctx.setEnvironment(prodEnv); ctx.setEnvironment(prodWebEnv);
ctx.refresh(); ctx.refresh();
assertHasEnvironment(ctx, prodEnv); assertHasEnvironment(ctx, prodWebEnv);
assertEnvironmentBeanRegistered(ctx); assertEnvironmentBeanRegistered(ctx);
assertEnvironmentAwareInvoked(ctx, prodEnv); assertEnvironmentAwareInvoked(ctx, prodWebEnv);
} }
@Test @Test
public void xmlWebApplicationContext() { public void xmlWebApplicationContext() {
AbstractRefreshableWebApplicationContext ctx = new XmlWebApplicationContext(); AbstractRefreshableWebApplicationContext ctx = new XmlWebApplicationContext();
ctx.setConfigLocation("classpath:" + XML_PATH); ctx.setConfigLocation("classpath:" + XML_PATH);
ctx.setEnvironment(prodEnv); ctx.setEnvironment(prodWebEnv);
ctx.refresh(); ctx.refresh();
assertHasEnvironment(ctx, prodEnv); assertHasEnvironment(ctx, prodWebEnv);
assertEnvironmentBeanRegistered(ctx); assertEnvironmentBeanRegistered(ctx);
assertEnvironmentAwareInvoked(ctx, prodEnv); assertEnvironmentAwareInvoked(ctx, prodWebEnv);
assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false)); assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true)); assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
} }
@ -394,24 +398,24 @@ public class EnvironmentIntegrationTests {
registerEnvironmentBeanDefinition(ctx); registerEnvironmentBeanDefinition(ctx);
ctx.setEnvironment(prodEnv); ctx.setEnvironment(prodWebEnv);
ctx.refresh(); ctx.refresh();
assertHasEnvironment(ctx, prodEnv); assertHasEnvironment(ctx, prodWebEnv);
assertEnvironmentBeanRegistered(ctx); assertEnvironmentBeanRegistered(ctx);
assertEnvironmentAwareInvoked(ctx, prodEnv); assertEnvironmentAwareInvoked(ctx, prodWebEnv);
} }
@Test @Test
public void annotationConfigWebApplicationContext() { public void annotationConfigWebApplicationContext() {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.setEnvironment(prodEnv); ctx.setEnvironment(prodWebEnv);
ctx.setConfigLocation(EnvironmentAwareBean.class.getName()); ctx.setConfigLocation(EnvironmentAwareBean.class.getName());
ctx.refresh(); ctx.refresh();
assertHasEnvironment(ctx, prodEnv); assertHasEnvironment(ctx, prodWebEnv);
assertEnvironmentBeanRegistered(ctx); assertEnvironmentBeanRegistered(ctx);
assertEnvironmentAwareInvoked(ctx, prodEnv); assertEnvironmentAwareInvoked(ctx, prodWebEnv);
} }
@Test @Test

6
org.springframework.web.servlet/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java

@ -1,12 +1,12 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2012 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

7
org.springframework.web/src/main/java/org/springframework/web/context/ConfigurableWebApplicationContext.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -71,6 +71,11 @@ public interface ConfigurableWebApplicationContext extends WebApplicationContext
*/ */
ServletConfig getServletConfig(); ServletConfig getServletConfig();
/**
* Return the {@link ConfigurableWebEnvironment} used by this web application context.
*/
ConfigurableWebEnvironment getEnvironment();
/** /**
* Set the namespace for this web application context, * Set the namespace for this web application context,
* to be used for building a default context config location. * to be used for building a default context config location.

46
org.springframework.web/src/main/java/org/springframework/web/context/ConfigurableWebEnvironment.java

@ -0,0 +1,46 @@
/*
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.context;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import org.springframework.core.env.ConfigurableEnvironment;
/**
* Specialization of {@link ConfigurableEnvironment} allowing initialization of
* servlet-related {@link org.springframework.core.env.PropertySource} objects at the
* earliest moment the {@link ServletContext} and (optionally) {@link ServletConfig}
* become available.
*
* @author Chris Beams
* @since 3.1.2
* @see ConfigurableWebApplicationContext#getEnvironment()
*/
public interface ConfigurableWebEnvironment extends ConfigurableEnvironment {
/**
* Replace any {@linkplain
* org.springframework.core.env.PropertySource.StubPropertySource stub property source}
* instances acting as placeholders with real servlet context/config property sources
* using the given parameters.
* @param servletContext the {@link ServletContext} (may not be {@code null})
* @param servletConfig the {@link ServletContext} ({@code null} if not available)
*/
void initPropertySources(ServletContext servletContext, ServletConfig servletConfig);
}

18
org.springframework.web/src/main/java/org/springframework/web/context/ContextLoader.java

@ -44,7 +44,6 @@ import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.context.support.WebApplicationContextUtils;
/** /**
* Performs the actual initialization work for the root application context. * Performs the actual initialization work for the root application context.
@ -202,7 +201,7 @@ public class ContextLoader {
* ContextLoaderListener} subclass as a {@code <listener>} within {@code web.xml}, as * ContextLoaderListener} subclass as a {@code <listener>} within {@code web.xml}, as
* a no-arg constructor is required. * a no-arg constructor is required.
* <p>The created application context will be registered into the ServletContext under * <p>The created application context will be registered into the ServletContext under
* the attribute name {@link WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE} * the attribute name {@link WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE}
* and subclasses are free to call the {@link #closeWebApplicationContext} method on * and subclasses are free to call the {@link #closeWebApplicationContext} method on
* container shutdown to close the application context. * container shutdown to close the application context.
* @see #ContextLoader(WebApplicationContext) * @see #ContextLoader(WebApplicationContext)
@ -238,7 +237,7 @@ public class ContextLoader {
* <p>See {@link org.springframework.web.WebApplicationInitializer} for usage examples. * <p>See {@link org.springframework.web.WebApplicationInitializer} for usage examples.
* <p>In any case, the given application context will be registered into the * <p>In any case, the given application context will be registered into the
* ServletContext under the attribute name {@link * ServletContext under the attribute name {@link
* WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE} and subclasses are * WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE} and subclasses are
* free to call the {@link #closeWebApplicationContext} method on container shutdown * free to call the {@link #closeWebApplicationContext} method on container shutdown
* to close the application context. * to close the application context.
* @param context the application context to manage * @param context the application context to manage
@ -325,7 +324,6 @@ public class ContextLoader {
* <p>In addition, {@link #customizeContext} gets called prior to refreshing the * <p>In addition, {@link #customizeContext} gets called prior to refreshing the
* context, allowing subclasses to perform custom modifications to the context. * context, allowing subclasses to perform custom modifications to the context.
* @param sc current servlet context * @param sc current servlet context
* @param parent the parent ApplicationContext to use, or <code>null</code> if none
* @return the root WebApplicationContext * @return the root WebApplicationContext
* @see ConfigurableWebApplicationContext * @see ConfigurableWebApplicationContext
*/ */
@ -343,7 +341,7 @@ public class ContextLoader {
/** /**
* @deprecated as of Spring 3.1 in favor of * @deprecated as of Spring 3.1 in favor of
* {@link #createWebApplicationContext(ServletContext)} and * {@link #createWebApplicationContext(ServletContext)} and
* {@link #configureAndRefreshWebApplicationContext(WebApplicationContext, ServletContext)} * {@link #configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext, ServletContext)}
*/ */
@Deprecated @Deprecated
protected WebApplicationContext createWebApplicationContext(ServletContext sc, ApplicationContext parent) { protected WebApplicationContext createWebApplicationContext(ServletContext sc, ApplicationContext parent) {
@ -486,15 +484,9 @@ public class ContextLoader {
initializerInstances.add(BeanUtils.instantiateClass(initializerClass)); initializerInstances.add(BeanUtils.instantiateClass(initializerClass));
} }
Collections.sort(initializerInstances, new AnnotationAwareOrderComparator()); applicationContext.getEnvironment().initPropertySources(servletContext, null);
// eagerly attempt to initialize servlet property sources in case initializers
// below depend on accessing context-params via the Environment API. Note that
// depending on application context implementation, this initialization will be
// attempted again during context refresh.
WebApplicationContextUtils.initServletPropertySources(
applicationContext.getEnvironment().getPropertySources(), servletContext);
Collections.sort(initializerInstances, new AnnotationAwareOrderComparator());
for (ApplicationContextInitializer<ConfigurableApplicationContext> initializer : initializerInstances) { for (ApplicationContextInitializer<ConfigurableApplicationContext> initializer : initializerInstances) {
initializer.initialize(applicationContext); initializer.initialize(applicationContext);
} }

16
org.springframework.web/src/main/java/org/springframework/web/context/support/AbstractRefreshableWebApplicationContext.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2009 the original author or authors. * Copyright 2002-2012 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,9 @@ import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.ui.context.Theme; import org.springframework.ui.context.Theme;
import org.springframework.ui.context.ThemeSource; import org.springframework.ui.context.ThemeSource;
import org.springframework.ui.context.support.UiApplicationContextUtils; import org.springframework.ui.context.support.UiApplicationContextUtils;
import org.springframework.util.Assert;
import org.springframework.web.context.ConfigurableWebApplicationContext; import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.context.ConfigurableWebEnvironment;
import org.springframework.web.context.ServletConfigAware; import org.springframework.web.context.ServletConfigAware;
import org.springframework.web.context.ServletContextAware; import org.springframework.web.context.ServletContextAware;
@ -139,6 +141,14 @@ public abstract class AbstractRefreshableWebApplicationContext extends AbstractR
return new StandardServletEnvironment(); return new StandardServletEnvironment();
} }
@Override
public ConfigurableWebEnvironment getEnvironment() {
ConfigurableEnvironment env = super.getEnvironment();
Assert.isInstanceOf(ConfigurableWebEnvironment.class, env,
"ConfigurableWebApplicationContext environment must be of type " +
"ConfigurableWebEnvironment");
return (ConfigurableWebEnvironment) env;
}
/** /**
* Register request/session scopes, a {@link ServletContextAwareProcessor}, etc. * Register request/session scopes, a {@link ServletContextAwareProcessor}, etc.
@ -186,9 +196,7 @@ public abstract class AbstractRefreshableWebApplicationContext extends AbstractR
@Override @Override
protected void initPropertySources() { protected void initPropertySources() {
super.initPropertySources(); super.initPropertySources();
WebApplicationContextUtils.initServletPropertySources( this.getEnvironment().initPropertySources(this.servletContext, this.servletConfig);
this.getEnvironment().getPropertySources(), this.servletContext,
this.servletConfig);
} }
public Theme getTheme(String themeName) { public Theme getTheme(String themeName) {

16
org.springframework.web/src/main/java/org/springframework/web/context/support/GenericWebApplicationContext.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2011 the original author or authors. * Copyright 2002-2012 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,9 +28,11 @@ import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.ui.context.Theme; import org.springframework.ui.context.Theme;
import org.springframework.ui.context.ThemeSource; import org.springframework.ui.context.ThemeSource;
import org.springframework.ui.context.support.UiApplicationContextUtils; import org.springframework.ui.context.support.UiApplicationContextUtils;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.context.ConfigurableWebApplicationContext; import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.context.ConfigurableWebEnvironment;
import org.springframework.web.context.ServletContextAware; import org.springframework.web.context.ServletContextAware;
/** /**
@ -130,6 +132,15 @@ public class GenericWebApplicationContext extends GenericApplicationContext
return new StandardServletEnvironment(); return new StandardServletEnvironment();
} }
@Override
public ConfigurableWebEnvironment getEnvironment() {
ConfigurableEnvironment env = super.getEnvironment();
Assert.isInstanceOf(ConfigurableWebEnvironment.class, env,
"ConfigurableWebApplicationContext environment must be of type " +
"ConfigurableWebEnvironment");
return (ConfigurableWebEnvironment) env;
}
/** /**
* Register ServletContextAwareProcessor. * Register ServletContextAwareProcessor.
* @see ServletContextAwareProcessor * @see ServletContextAwareProcessor
@ -176,8 +187,7 @@ public class GenericWebApplicationContext extends GenericApplicationContext
@Override @Override
protected void initPropertySources() { protected void initPropertySources() {
super.initPropertySources(); super.initPropertySources();
WebApplicationContextUtils.initServletPropertySources( this.getEnvironment().initPropertySources(this.servletContext, null);
this.getEnvironment().getPropertySources(), this.servletContext);
} }
public Theme getTheme(String themeName) { public Theme getTheme(String themeName) {

17
org.springframework.web/src/main/java/org/springframework/web/context/support/StandardServletEnvironment.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2011 the original author or authors. * Copyright 2002-2012 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,6 +26,7 @@ import org.springframework.core.env.PropertySource.StubPropertySource;
import org.springframework.core.env.StandardEnvironment; import org.springframework.core.env.StandardEnvironment;
import org.springframework.jndi.JndiLocatorDelegate; import org.springframework.jndi.JndiLocatorDelegate;
import org.springframework.jndi.JndiPropertySource; import org.springframework.jndi.JndiPropertySource;
import org.springframework.web.context.ConfigurableWebEnvironment;
/** /**
* {@link Environment} implementation to be used by {@code Servlet}-based web * {@link Environment} implementation to be used by {@code Servlet}-based web
@ -40,7 +41,8 @@ import org.springframework.jndi.JndiPropertySource;
* @since 3.1 * @since 3.1
* @see StandardEnvironment * @see StandardEnvironment
*/ */
public class StandardServletEnvironment extends StandardEnvironment { public class StandardServletEnvironment extends StandardEnvironment
implements ConfigurableWebEnvironment {
/** Servlet context init parameters property source name: {@value} */ /** Servlet context init parameters property source name: {@value} */
public static final String SERVLET_CONTEXT_PROPERTY_SOURCE_NAME = "servletContextInitParams"; public static final String SERVLET_CONTEXT_PROPERTY_SOURCE_NAME = "servletContextInitParams";
@ -68,15 +70,15 @@ public class StandardServletEnvironment extends StandardEnvironment {
* environment variables contributed by the {@link StandardEnvironment} superclass. * environment variables contributed by the {@link StandardEnvironment} superclass.
* <p>The {@code Servlet}-related property sources are added as {@link * <p>The {@code Servlet}-related property sources are added as {@link
* StubPropertySource stubs} at this stage, and will be {@linkplain * StubPropertySource stubs} at this stage, and will be {@linkplain
* WebApplicationContextUtils#initServletPropertySources fully initialized} once the * #initPropertySources(ServletContext) fully initialized} once the actual
* actual {@link ServletConfig} and {@link ServletContext} objects become available. * {@link ServletContext} object becomes available.
* @see StandardEnvironment#customizePropertySources * @see StandardEnvironment#customizePropertySources
* @see org.springframework.core.env.AbstractEnvironment#customizePropertySources * @see org.springframework.core.env.AbstractEnvironment#customizePropertySources
* @see ServletConfigPropertySource * @see ServletConfigPropertySource
* @see ServletContextPropertySource * @see ServletContextPropertySource
* @see org.springframework.jndi.JndiPropertySource * @see org.springframework.jndi.JndiPropertySource
* @see org.springframework.context.support.AbstractApplicationContext#initPropertySources * @see org.springframework.context.support.AbstractApplicationContext#initPropertySources
* @see WebApplicationContextUtils#initServletPropertySources * @see #initPropertySources(ServletContext)
*/ */
@Override @Override
protected void customizePropertySources(MutablePropertySources propertySources) { protected void customizePropertySources(MutablePropertySources propertySources) {
@ -88,4 +90,9 @@ public class StandardServletEnvironment extends StandardEnvironment {
super.customizePropertySources(propertySources); super.customizePropertySources(propertySources);
} }
public void initPropertySources(ServletContext servletContext, ServletConfig servletConfig) {
WebApplicationContextUtils.initServletPropertySources(
this.getPropertySources(), servletContext, servletConfig);
}
} }

13
org.springframework.web/src/main/java/org/springframework/web/context/support/StaticWebApplicationContext.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2011 the original author or authors. * Copyright 2002-2012 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,9 @@ import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.ui.context.Theme; import org.springframework.ui.context.Theme;
import org.springframework.ui.context.ThemeSource; import org.springframework.ui.context.ThemeSource;
import org.springframework.ui.context.support.UiApplicationContextUtils; import org.springframework.ui.context.support.UiApplicationContextUtils;
import org.springframework.util.Assert;
import org.springframework.web.context.ConfigurableWebApplicationContext; import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.context.ConfigurableWebEnvironment;
import org.springframework.web.context.ServletConfigAware; import org.springframework.web.context.ServletConfigAware;
import org.springframework.web.context.ServletContextAware; import org.springframework.web.context.ServletContextAware;
@ -167,6 +169,15 @@ public class StaticWebApplicationContext extends StaticApplicationContext
return new StandardServletEnvironment(); return new StandardServletEnvironment();
} }
@Override
public ConfigurableWebEnvironment getEnvironment() {
ConfigurableEnvironment env = super.getEnvironment();
Assert.isInstanceOf(ConfigurableWebEnvironment.class, env,
"ConfigurableWebApplication environment must be of type " +
"ConfigurableWebEnvironment");
return (ConfigurableWebEnvironment) env;
}
/** /**
* Initialize the theme capability. * Initialize the theme capability.
*/ */

Loading…
Cancel
Save