Class Overview
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.
Summary
Public Constructors |
|
DefaultWebEnvironment()
Create a new Environment populated with the property sources contributed by
superclasses as well as:
- {@value #SERVLET_CONFIG_PROPERTY_SOURCE_NAME}
- {@value #SERVLET_CONTEXT_PROPERTY_SOURCE_NAME}
- (optionally)
"jndiPropertySource"
Properties present in {@value #SERVLET_CONFIG_PROPERTY_SOURCE_NAME} will
take precedence over those in {@value #SERVLET_CONTEXT_PROPERTY_SOURCE_NAME}.
|
[Expand]
Inherited Methods |
From class
org.springframework.core.env.AbstractEnvironment
boolean
|
acceptsProfiles(String... profiles)
|
boolean
|
containsProperty(String key)
Return whether the given property key is available for resolution.
|
Set<String>
|
doGetActiveProfiles()
|
Set<String>
|
doGetDefaultProfiles()
|
String[]
|
getActiveProfiles()
Return the set of profiles explicitly made active for this environment.
|
ConversionService
|
getConversionService()
|
String[]
|
getDefaultProfiles()
Return the set of profiles to be active by default when no active profiles have been set explicitly.
|
<T>
T
|
getProperty(String key, Class<T> targetType)
Return the property value associated with the given key, or null
if the key cannot be resolved.
|
String
|
getProperty(String key)
Return the property value associated with the given key.
|
ConfigurablePropertyResolver
|
getPropertyResolver()
|
MutablePropertySources
|
getPropertySources()
|
String
|
getRequiredProperty(String key)
Return the property value associated with the given key, converted to the given
targetType (never null ).
|
<T>
T
|
getRequiredProperty(String key, Class<T> targetType)
Return the property value associated with the given key, converted to the given
targetType (never null ).
|
Map<String, Object>
|
getSystemEnvironment()
Return the value of getenv() if allowed by the current SecurityManager,
otherwise return a map implementation that will attempt to access individual keys using calls to
getenv(String) .
|
Map<String, Object>
|
getSystemProperties()
Return the value of getProperties() if allowed by the current SecurityManager,
otherwise return a map implementation that will attempt to access individual keys using calls to
getProperty(String) .
|
String
|
resolvePlaceholders(String text)
Resolve ${...} placeholders in the given text, replacing them with corresponding
property values as resolved by getProperty(String) .
|
String
|
resolveRequiredPlaceholders(String text)
Resolve ${...} placeholders in the given text, replacing them with corresponding
property values as resolved by getProperty(String) .
|
void
|
setActiveProfiles(String... profiles)
Specify the set of profiles active for this Environment.
|
void
|
setConversionService(ConversionService conversionService)
|
void
|
setDefaultProfiles(String... profiles)
Specify the set of profiles to be made active by default if no other profiles
are explicitly made active through setActiveProfiles(String...) .
|
void
|
setPlaceholderPrefix(String placeholderPrefix)
|
void
|
setPlaceholderSuffix(String placeholderSuffix)
|
void
|
setValueSeparator(String valueSeparator)
|
String
|
toString()
|
|
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
|
From interface
org.springframework.core.env.ConfigurableEnvironment
|
From interface
org.springframework.core.env.ConfigurablePropertyResolver
|
From interface
org.springframework.core.env.Environment
|
From interface
org.springframework.core.env.PropertyResolver
|
Constants
public
static
final
String
SERVLET_CONFIG_PROPERTY_SOURCE_NAME
Servlet config init parameters property source name: {@value }
Constant Value:
"servletConfigInitParams"
public
static
final
String
SERVLET_CONTEXT_PROPERTY_SOURCE_NAME
Servlet context init parameters property source name: {@value }
Constant Value:
"servletContextInitParams"
Public Constructors
public
DefaultWebEnvironment
()
Create a new Environment
populated with the property sources contributed by
superclasses as well as:
- {@value #SERVLET_CONFIG_PROPERTY_SOURCE_NAME}
- {@value #SERVLET_CONTEXT_PROPERTY_SOURCE_NAME}
- (optionally)
"jndiPropertySource"
Properties present in {@value #SERVLET_CONFIG_PROPERTY_SOURCE_NAME} will
take precedence over those in {@value #SERVLET_CONTEXT_PROPERTY_SOURCE_NAME}.
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.