org.springframework.web.context.support
Class StandardServletEnvironment

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

public class StandardServletEnvironment
extends StandardEnvironment
implements ConfigurableWebEnvironment

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

Contributes ServletConfig, ServletContext, and JNDI-based PropertySource instances. See customizePropertySources(org.springframework.core.env.MutablePropertySources) method documentation for details.

Since:
3.1
Author:
Chris Beams
See Also:
StandardEnvironment

Field Summary
static String JNDI_PROPERTY_SOURCE_NAME
          JNDI property source name: "jndiProperties"
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.StandardEnvironment
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, RESERVED_DEFAULT_PROFILE_NAME
 
Constructor Summary
StandardServletEnvironment()
           
 
Method Summary
protected  void customizePropertySources(MutablePropertySources propertySources)
          Customize the set of property sources with those contributed by superclasses as well as those appropriate for standard servlet-based environments: "servletConfigInitParams" "servletContextInitParams" "jndiProperties"
 void initPropertySources(ServletContext servletContext, ServletConfig servletConfig)
          Replace any stub property source instances acting as placeholders with real servlet context/config property sources using the given parameters.
 
Methods inherited from class org.springframework.core.env.AbstractEnvironment
acceptsProfiles, addActiveProfile, containsProperty, doGetActiveProfiles, doGetDefaultProfiles, getActiveProfiles, getConversionService, getDefaultProfiles, getProperty, getProperty, getProperty, getProperty, getPropertyAsClass, getPropertySources, getRequiredProperty, getRequiredProperty, getReservedDefaultProfiles, getSystemEnvironment, getSystemProperties, isProfileActive, merge, resolvePlaceholders, resolveRequiredPlaceholders, setActiveProfiles, setConversionService, setDefaultProfiles, setPlaceholderPrefix, setPlaceholderSuffix, setRequiredProperties, setValueSeparator, toString, validateProfile, validateRequiredProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.core.env.ConfigurableEnvironment
addActiveProfile, getPropertySources, getSystemEnvironment, getSystemProperties, merge, setActiveProfiles, setDefaultProfiles
 
Methods inherited from interface org.springframework.core.env.Environment
acceptsProfiles, getActiveProfiles, getDefaultProfiles
 
Methods inherited from interface org.springframework.core.env.ConfigurablePropertyResolver
getConversionService, setConversionService, setPlaceholderPrefix, setPlaceholderSuffix, setRequiredProperties, setValueSeparator, validateRequiredProperties
 
Methods inherited from interface org.springframework.core.env.PropertyResolver
containsProperty, getProperty, getProperty, getProperty, getProperty, getPropertyAsClass, getRequiredProperty, getRequiredProperty, resolvePlaceholders, resolveRequiredPlaceholders
 

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

JNDI_PROPERTY_SOURCE_NAME

public static final String JNDI_PROPERTY_SOURCE_NAME
JNDI property source name: "jndiProperties"

See Also:
Constant Field Values
Constructor Detail

StandardServletEnvironment

public StandardServletEnvironment()
Method Detail

customizePropertySources

protected void customizePropertySources(MutablePropertySources propertySources)
Customize the set of property sources with those contributed by superclasses as well as those appropriate for standard servlet-based environments:

Properties present in "servletConfigInitParams" will take precedence over those in "servletContextInitParams", and properties found in either of the above take precedence over those found in "jndiProperties".

Properties in any of the above will take precedence over system properties and environment variables contributed by the StandardEnvironment superclass.

The Servlet-related property sources are added as stubs at this stage, and will be fully initialized once the actual ServletContext object becomes available.

Overrides:
customizePropertySources in class StandardEnvironment
See Also:
StandardEnvironment.customizePropertySources(org.springframework.core.env.MutablePropertySources), AbstractEnvironment.customizePropertySources(org.springframework.core.env.MutablePropertySources), ServletConfigPropertySource, ServletContextPropertySource, JndiPropertySource, AbstractApplicationContext.initPropertySources(), #initPropertySources(ServletContext)

initPropertySources

public void initPropertySources(ServletContext servletContext,
                                ServletConfig servletConfig)
Description copied from interface: ConfigurableWebEnvironment
Replace any stub property source instances acting as placeholders with real servlet context/config property sources using the given parameters.

Specified by:
initPropertySources in interface ConfigurableWebEnvironment
Parameters:
servletContext - the ServletContext (may not be null)
servletConfig - the ServletContext (null if not available)