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.
StandardEnvironment
Modifier and Type | Field and Description |
---|---|
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".
|
SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
ACTIVE_PROFILES_PROPERTY_NAME, DEFAULT_PROFILES_PROPERTY_NAME, IGNORE_GETENV_PROPERTY_NAME, logger, RESERVED_DEFAULT_PROFILE_NAME
Modifier | Constructor and Description |
---|---|
|
StandardServletEnvironment()
Create a new
StandardServletEnvironment instance. |
protected |
StandardServletEnvironment(MutablePropertySources propertySources)
Create a new
StandardServletEnvironment instance with a specific MutablePropertySources instance. |
Modifier and Type | Method and Description |
---|---|
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.
|
acceptsProfiles, acceptsProfiles, addActiveProfile, containsProperty, createPropertyResolver, doGetActiveProfiles, doGetActiveProfilesProperty, doGetDefaultProfiles, doGetDefaultProfilesProperty, getActiveProfiles, getConversionService, getDefaultProfiles, getProperty, getProperty, getProperty, getProperty, getPropertyResolver, getPropertySources, getRequiredProperty, getRequiredProperty, getReservedDefaultProfiles, getSystemEnvironment, getSystemProperties, isProfileActive, merge, resolvePlaceholders, resolveRequiredPlaceholders, setActiveProfiles, setConversionService, setDefaultProfiles, setIgnoreUnresolvableNestedPlaceholders, setPlaceholderPrefix, setPlaceholderSuffix, setRequiredProperties, setValueSeparator, suppressGetenvAccess, toString, validateProfile, validateRequiredProperties
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addActiveProfile, getPropertySources, getSystemEnvironment, getSystemProperties, merge, setActiveProfiles, setDefaultProfiles
acceptsProfiles, acceptsProfiles, getActiveProfiles, getDefaultProfiles
getConversionService, setConversionService, setIgnoreUnresolvableNestedPlaceholders, setPlaceholderPrefix, setPlaceholderSuffix, setRequiredProperties, setValueSeparator, validateRequiredProperties
containsProperty, getProperty, getProperty, getProperty, getProperty, getRequiredProperty, getRequiredProperty, resolvePlaceholders, resolveRequiredPlaceholders
public static final String SERVLET_CONTEXT_PROPERTY_SOURCE_NAME
public static final String SERVLET_CONFIG_PROPERTY_SOURCE_NAME
public static final String JNDI_PROPERTY_SOURCE_NAME
public StandardServletEnvironment()
StandardServletEnvironment
instance.protected StandardServletEnvironment(MutablePropertySources propertySources)
StandardServletEnvironment
instance with a specific MutablePropertySources
instance.propertySources
- property sources to useprotected void customizePropertySources(MutablePropertySources propertySources)
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.
Addition of "jndiProperties" can be disabled with
JndiLocatorDelegate.IGNORE_JNDI_PROPERTY_NAME
.
customizePropertySources
in class StandardEnvironment
StandardEnvironment.customizePropertySources(org.springframework.core.env.MutablePropertySources)
,
AbstractEnvironment.customizePropertySources(org.springframework.core.env.MutablePropertySources)
,
ServletConfigPropertySource
,
ServletContextPropertySource
,
JndiPropertySource
,
AbstractApplicationContext.initPropertySources()
,
initPropertySources(ServletContext, ServletConfig)
public void initPropertySources(@Nullable ServletContext servletContext, @Nullable ServletConfig servletConfig)
ConfigurableWebEnvironment
initPropertySources
in interface ConfigurableWebEnvironment
servletContext
- the ServletContext
(may not be null
)servletConfig
- the ServletConfig
(null
if not available)WebApplicationContextUtils.initServletPropertySources(
org.springframework.core.env.MutablePropertySources, ServletContext, ServletConfig)