Top Description Fields Constructors Methods
org.springframework.web.context.support

public Class StandardServletEnvironment

extends StandardEnvironment
implements ConfigurableWebEnvironment
Class Inheritance
All Implemented Interfaces
org.springframework.web.context.ConfigurableWebEnvironment, org.springframework.core.env.ConfigurableEnvironment, org.springframework.core.env.ConfigurablePropertyResolver, org.springframework.core.env.PropertyResolver, org.springframework.core.env.Environment
Imports
jakarta.servlet.ServletConfig, .ServletContext, org.springframework.core.env.Environment, .MutablePropertySources, .PropertySource, .PropertySource.StubPropertySource, .StandardEnvironment, org.springframework.jndi.JndiLocatorDelegate, .JndiPropertySource, org.springframework.lang.Nullable, org.springframework.util.ClassUtils, org.springframework.web.context.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 method documentation for details.

Authors
Chris Beams, Juergen Hoeller
Since
3.1
See Also
StandardEnvironment

Field Summary

Modifier and TypeField and Description
public static final String
JNDI_PROPERTY_SOURCE_NAME

JNDI property source name: jndiProperties.

private static final boolean
public static final String
SERVLET_CONFIG_PROPERTY_SOURCE_NAME

Servlet config init parameters property source name: servletConfigInitParams.

public static final String
SERVLET_CONTEXT_PROPERTY_SOURCE_NAME

Servlet context init parameters property source name: servletContextInitParams.

Inherited from org.springframework.core.env.StandardEnvironment:
SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAMESYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME

Constructor Summary

AccessConstructor and Description
public
StandardServletEnvironment()

Create a new StandardServletEnvironment instance.

protected
StandardServletEnvironment(MutablePropertySources
property sources to use
propertySources
)

Create a new StandardServletEnvironment instance with a specific MutablePropertySources instance.

Method Summary

Modifier and TypeMethod and Description
protected void
customizePropertySources(MutablePropertySources propertySources)

Overrides org.springframework.core.env.StandardEnvironment.customizePropertySources.

Customize the set of property sources with those contributed by superclasses as well as those appropriate for standard servlet-based environments:
  • servletConfigInitParams
  • servletContextInitParams
  • jndiProperties
public void
initPropertySources(ServletContext
the ServletContext (may not be null)
servletContext
,
ServletConfig
the ServletConfig (null if not available)
servletConfig
)

Implements org.springframework.web.context.ConfigurableWebEnvironment.initPropertySources.

Replace any stub property source instances acting as placeholders with real servlet context/config property sources using the given parameters.

Field Detail

JNDI_PROPERTY_SOURCE_NAMEback to summary
public static final String JNDI_PROPERTY_SOURCE_NAME

JNDI property source name: jndiProperties.

jndiPresentback to summary
private static final boolean jndiPresent
SERVLET_CONFIG_PROPERTY_SOURCE_NAMEback to summary
public static final String SERVLET_CONFIG_PROPERTY_SOURCE_NAME

Servlet config init parameters property source name: servletConfigInitParams.

SERVLET_CONTEXT_PROPERTY_SOURCE_NAMEback to summary
public static final String SERVLET_CONTEXT_PROPERTY_SOURCE_NAME

Servlet context init parameters property source name: servletContextInitParams.

Constructor Detail

StandardServletEnvironmentback to summary
public StandardServletEnvironment()

Create a new StandardServletEnvironment instance.

StandardServletEnvironmentback to summary
protected StandardServletEnvironment(MutablePropertySources propertySources)

Create a new StandardServletEnvironment instance with a specific MutablePropertySources instance.

Parameters
propertySources:MutablePropertySources

property sources to use

Since
5.3.4

Method Detail

customizePropertySourcesback to summary
protected void customizePropertySources(MutablePropertySources propertySources)

Overrides org.springframework.core.env.StandardEnvironment.customizePropertySources.

Customize the set of property sources with those contributed by superclasses as well as those appropriate for standard servlet-based environments:

  • servletConfigInitParams
  • servletContextInitParams
  • jndiProperties

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.

Annotations
@Override
See Also
StandardEnvironment#customizePropertySources, org.springframework.core.env.AbstractEnvironment#customizePropertySources, ServletConfigPropertySource, ServletContextPropertySource, org.springframework.jndi.JndiPropertySource, org.springframework.context.support.AbstractApplicationContext#initPropertySources, initPropertySources(ServletContext, ServletConfig)
initPropertySourcesback to summary
public void initPropertySources(ServletContext servletContext, ServletConfig servletConfig)

Implements org.springframework.web.context.ConfigurableWebEnvironment.initPropertySources.

Doc from org.springframework.web.context.ConfigurableWebEnvironment.initPropertySources.

Replace any stub property source instances acting as placeholders with real servlet context/config property sources using the given parameters.

Parameters
servletContext:ServletContext

the ServletContext (may not be null)

servletConfig:ServletConfig

the ServletConfig (null if not available)

Annotations
@Override