org.springframework.web.context.support
Class DefaultWebEnvironment

java.lang.Object
  extended by org.springframework.core.env.AbstractEnvironment
      extended by org.springframework.core.env.DefaultEnvironment
          extended by org.springframework.web.context.support.DefaultWebEnvironment
All Implemented Interfaces:
ConfigurableEnvironment, ConfigurablePropertyResolver, Environment, PropertyResolver

public class DefaultWebEnvironment
extends DefaultEnvironment

Environment implementation to be used by Servlet-based web applications. All web-related (servlet-based) ApplicationContext classes initialize an instance by default.

Contributes ServletConfig- and ServletContext-based PropertySource instances. See the DefaultWebEnvironment() constructor for details.

After initial bootstrapping, property sources will be searched for the presence of a "jndiPropertySourceEnabled" property; if found, a JndiPropertySource will be added to this environment's PropertySources, with precedence higher than system properties and environment variables, but lower than that of ServletContext and ServletConfig init params.

Since:
3.1
Author:
Chris Beams
See Also:
DefaultEnvironment, DefaultPortletEnvironment

Field Summary
static String SERVLET_CONFIG_PROPERTY_SOURCE_NAME
          Servlet config init parameters property source name: "servletConfigInitParams"
static String SERVLET_CONTEXT_PROPERTY_SOURCE_NAME
          Servlet context init parameters property source name: "servletContextInitParams"
 
Fields inherited from class org.springframework.core.env.DefaultEnvironment
SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
 
Fields inherited from class org.springframework.core.env.AbstractEnvironment
ACTIVE_PROFILES_PROPERTY_NAME, DEFAULT_PROFILES_PROPERTY_NAME, logger
 
Constructor Summary
DefaultWebEnvironment()
          Create a new Environment populated with the property sources contributed by superclasses as well as: "servletConfigInitParams" "servletContextInitParams" (optionally) "jndiPropertySource"
 
Method Summary
 
Methods inherited from class org.springframework.core.env.AbstractEnvironment
acceptsProfiles, containsProperty, doGetActiveProfiles, doGetDefaultProfiles, getActiveProfiles, getConversionService, getDefaultProfiles, getProperty, getProperty, getPropertyResolver, getPropertySources, getRequiredProperty, getRequiredProperty, getSystemEnvironment, getSystemProperties, resolvePlaceholders, resolveRequiredPlaceholders, setActiveProfiles, setConversionService, setDefaultProfiles, setPlaceholderPrefix, setPlaceholderSuffix, setValueSeparator, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SERVLET_CONTEXT_PROPERTY_SOURCE_NAME

public static final String SERVLET_CONTEXT_PROPERTY_SOURCE_NAME
Servlet context init parameters property source name: "servletContextInitParams"

See Also:
Constant Field Values

SERVLET_CONFIG_PROPERTY_SOURCE_NAME

public static final String SERVLET_CONFIG_PROPERTY_SOURCE_NAME
Servlet config init parameters property source name: "servletConfigInitParams"

See Also:
Constant Field Values
Constructor Detail

DefaultWebEnvironment

public DefaultWebEnvironment()
Create a new Environment populated with the property sources contributed by superclasses as well as:

Properties present in "servletConfigInitParams" will take precedence over those in "servletContextInitParams". Properties in either will take precedence over system properties and environment variables.

The Servlet-related property sources are added as stubs for now, and will be fully initialized once the actual ServletConfig and ServletContext objects are available.

If the "jndiPropertySourceEnabled" property is present in any of the default property sources, a JndiPropertySource will be added as well, with precedence lower than servlet property sources, but higher than system properties and environment variables.

See Also:
DefaultEnvironment.DefaultEnvironment(), ServletConfigPropertySource, ServletContextPropertySource, JndiPropertySource, AbstractApplicationContext.initPropertySources(), WebApplicationContextUtils.initServletPropertySources(org.springframework.core.env.MutablePropertySources, javax.servlet.ServletContext)