Rename {DefaultWeb=>StandardServlet}Environment

Issue: SPR-8348
This commit is contained in:
Chris Beams
2011-05-20 03:55:56 +00:00
parent c06752ef72
commit f893b62a9b
14 changed files with 102 additions and 90 deletions

View File

@@ -132,11 +132,11 @@ public abstract class AbstractRefreshableWebApplicationContext extends AbstractR
}
/**
* Create and return a new {@link DefaultWebEnvironment}.
* Create and return a new {@link StandardServletEnvironment}.
*/
@Override
protected ConfigurableEnvironment createEnvironment() {
return new DefaultWebEnvironment();
return new StandardServletEnvironment();
}

View File

@@ -118,11 +118,11 @@ public class GenericWebApplicationContext extends GenericApplicationContext
/**
* Create and return a new {@link DefaultWebEnvironment}.
* Create and return a new {@link StandardServletEnvironment}.
*/
@Override
protected ConfigurableEnvironment createEnvironment() {
return new DefaultWebEnvironment();
return new StandardServletEnvironment();
}
/**

View File

@@ -59,7 +59,7 @@ import org.springframework.web.context.ServletContextAware;
* @see javax.servlet.ServletContext#getInitParameter(String)
* @see javax.servlet.ServletContext#getAttribute(String)
* @deprecated in Spring 3.1 in favor of {@link org.springframework.context.support.PropertySourcesPlaceholderConfigurer}
* in conjunction with {@link org.springframework.web.context.support.DefaultWebEnvironment}.
* in conjunction with {@link org.springframework.web.context.support.StandardServletEnvironment}.
*/
@Deprecated
public class ServletContextPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer

View File

@@ -32,20 +32,22 @@ import org.springframework.jndi.JndiPropertySource;
* applications. All web-related (servlet-based) {@code ApplicationContext} classes
* initialize an instance by default.
*
* <p>Contributes {@code ServletConfig}- and {@code ServletContext}-based {@link PropertySource}
* instances. See the {@link #DefaultWebEnvironment()} constructor for details.
* <p>Contributes {@code ServletConfig}- and {@code ServletContext}-based
* {@link PropertySource} instances. See the {@link #customizePropertySources} method
* for details.
*
* <p>After initial bootstrapping, property sources will be searched for the presence of a
* "jndiPropertySourceEnabled" property; if found, a {@link JndiPropertySource} will be added
* to this environment's {@link PropertySources}, with precedence higher than system properties
* and environment variables, but lower than that of ServletContext and ServletConfig init params.
* "jndiPropertySourceEnabled" property; if found, a {@link JndiPropertySource} will be
* added to this environment's {@link PropertySources}, with precedence higher than system
* properties and environment variables, but lower than that of ServletContext and
* ServletConfig init params.
*
* @author Chris Beams
* @since 3.1
* @see StandardEnvironment
* @see DefaultPortletEnvironment
*/
public class DefaultWebEnvironment extends StandardEnvironment {
public class StandardServletEnvironment extends StandardEnvironment {
/** Servlet context init parameters property source name: {@value} */
public static final String SERVLET_CONTEXT_PROPERTY_SOURCE_NAME = "servletContextInitParams";
@@ -63,15 +65,17 @@ public class DefaultWebEnvironment extends StandardEnvironment {
* </ul>
* <p>Properties present in {@value #SERVLET_CONFIG_PROPERTY_SOURCE_NAME} will
* take precedence over those in {@value #SERVLET_CONTEXT_PROPERTY_SOURCE_NAME}.
* <p>Properties in any of the above will take precedence over system properties and environment
* variables contributed by the {@link StandardEnvironment} superclass.
* <p>The {@code Servlet}-related property sources are added as stubs for now, and will be
* {@linkplain WebApplicationContextUtils#initServletPropertySources fully initialized}
* once the actual {@link ServletConfig} and {@link ServletContext} objects are available.
* <p>Properties in any of the above will take precedence over system properties and
* environment variables contributed by the {@link StandardEnvironment} superclass.
* <p>The {@code Servlet}-related property sources are added as stubs for now, and
* will be {@linkplain WebApplicationContextUtils#initServletPropertySources fully
* initialized} once the actual {@link ServletConfig} and {@link ServletContext}
* objects are available.
* <p>If the {@link JndiPropertySource#JNDI_PROPERTY_SOURCE_ENABLED_FLAG "jndiPropertySourceEnabled"}
* property is present in any of the default property sources, a {@link JndiPropertySource} will
* be added as well, with precedence lower than servlet property sources, but higher than system
* properties and environment variables.
* property is present in any of the default property sources, a
* {@link JndiPropertySource} will be added as well, with precedence lower than
* servlet property sources, but higher than system properties and environment
* variables.
* @see StandardEnvironment#customizePropertySources
* @see ServletConfigPropertySource
* @see ServletContextPropertySource

View File

@@ -160,11 +160,11 @@ public class StaticWebApplicationContext extends StaticApplicationContext
}
/**
* Create and return a new {@link DefaultWebEnvironment}.
* Create and return a new {@link StandardServletEnvironment}.
*/
@Override
protected ConfigurableEnvironment createEnvironment() {
return new DefaultWebEnvironment();
return new StandardServletEnvironment();
}
/**

View File

@@ -247,13 +247,13 @@ public abstract class WebApplicationContextUtils {
public static void initServletPropertySources(
MutablePropertySources propertySources, ServletContext servletContext, ServletConfig servletConfig) {
Assert.notNull(propertySources, "propertySources must not be null");
if(servletContext != null && propertySources.contains(DefaultWebEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME)) {
propertySources.replace(DefaultWebEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME,
new ServletContextPropertySource(DefaultWebEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, servletContext));
if(servletContext != null && propertySources.contains(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME)) {
propertySources.replace(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME,
new ServletContextPropertySource(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, servletContext));
}
if(servletConfig != null && propertySources.contains(DefaultWebEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME)) {
propertySources.replace(DefaultWebEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME,
new ServletConfigPropertySource(DefaultWebEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME, servletConfig));
if(servletConfig != null && propertySources.contains(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME)) {
propertySources.replace(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME,
new ServletConfigPropertySource(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME, servletConfig));
}
}

View File

@@ -44,7 +44,7 @@ import org.springframework.core.io.ResourceLoader;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.context.ServletContextAware;
import org.springframework.web.context.support.DefaultWebEnvironment;
import org.springframework.web.context.support.StandardServletEnvironment;
import org.springframework.web.context.support.ServletContextResourceLoader;
import org.springframework.web.util.NestedServletException;
@@ -91,7 +91,7 @@ public abstract class GenericFilterBean implements
private String beanName;
private Environment environment = new DefaultWebEnvironment();
private Environment environment = new StandardServletEnvironment();
private ServletContext servletContext;
@@ -109,7 +109,7 @@ public abstract class GenericFilterBean implements
/**
* {@inheritDoc}
* <p>Any environment set here overrides the {@link DefaultWebEnvironment}
* <p>Any environment set here overrides the {@link StandardServletEnvironment}
* provided by default.
*/
public void setEnvironment(Environment environment) {