|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.core.io.support.PropertiesLoaderSupport
org.springframework.beans.factory.config.PropertyResourceConfigurer
org.springframework.beans.factory.config.PlaceholderConfigurerSupport
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer
PropertySourcesPlaceholderConfigurer
in conjunction with StandardServletEnvironment
.
@Deprecated public class ServletContextPropertyPlaceholderConfigurer
Subclass of PropertyPlaceholderConfigurer
that resolves placeholders as
ServletContext init parameters (that is, web.xml
context-param
entries).
Can be combined with "locations" and/or "properties" values in addition
to web.xml context-params. Alternatively, can be defined without local
properties, to resolve all placeholders as web.xml
context-params
(or JVM system properties).
If a placeholder could not be resolved against the provided local properties within the application, this configurer will fall back to ServletContext parameters. Can also be configured to let ServletContext init parameters override local properties (contextOverride=true).
Optionally supports searching for ServletContext attributes: If turned on, an otherwise unresolvable placeholder will matched against the corresponding ServletContext attribute, using its stringified value if found. This can be used to feed dynamic values into Spring's placeholder resolution.
If not running within a WebApplicationContext (or any other context that is able to satisfy the ServletContextAware callback), this class will behave like the default PropertyPlaceholderConfigurer. This allows for keeping ServletContextPropertyPlaceholderConfigurer definitions in test suites.
PropertiesLoaderSupport.setLocations(org.springframework.core.io.Resource[])
,
PropertiesLoaderSupport.setProperties(java.util.Properties)
,
PropertyPlaceholderConfigurer.setSystemPropertiesModeName(java.lang.String)
,
setContextOverride(boolean)
,
setSearchContextAttributes(boolean)
,
javax.servlet.ServletContext#getInitParameter(String)
,
javax.servlet.ServletContext#getAttribute(String)
Field Summary | |
---|---|
private boolean |
contextOverride
Deprecated. |
private boolean |
searchContextAttributes
Deprecated. |
private ServletContext |
servletContext
Deprecated. |
Fields inherited from class org.springframework.beans.factory.config.PropertyPlaceholderConfigurer |
---|
SYSTEM_PROPERTIES_MODE_FALLBACK, SYSTEM_PROPERTIES_MODE_NEVER, SYSTEM_PROPERTIES_MODE_OVERRIDE |
Fields inherited from class org.springframework.beans.factory.config.PlaceholderConfigurerSupport |
---|
DEFAULT_PLACEHOLDER_PREFIX, DEFAULT_PLACEHOLDER_SUFFIX, DEFAULT_VALUE_SEPARATOR, ignoreUnresolvablePlaceholders, nullValue, placeholderPrefix, placeholderSuffix, valueSeparator |
Fields inherited from class org.springframework.core.io.support.PropertiesLoaderSupport |
---|
localOverride, localProperties, logger, XML_FILE_EXTENSION |
Fields inherited from interface org.springframework.core.Ordered |
---|
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE |
Constructor Summary | |
---|---|
ServletContextPropertyPlaceholderConfigurer()
Deprecated. |
Method Summary | |
---|---|
protected java.lang.String |
resolvePlaceholder(java.lang.String placeholder,
java.util.Properties props)
Deprecated. Resolve the given placeholder using the given properties. |
protected java.lang.String |
resolvePlaceholder(java.lang.String placeholder,
ServletContext servletContext,
boolean searchContextAttributes)
Deprecated. Resolves the given placeholder using the init parameters and optionally also the attributes of the given ServletContext. |
void |
setContextOverride(boolean contextOverride)
Deprecated. Set whether ServletContext init parameters (and optionally also ServletContext attributes) should override local properties within the application. |
void |
setSearchContextAttributes(boolean searchContextAttributes)
Deprecated. Set whether to search for matching a ServletContext attribute before checking a ServletContext init parameter. |
void |
setServletContext(ServletContext servletContext)
Deprecated. Set the ServletContext to resolve placeholders against. |
Methods inherited from class org.springframework.beans.factory.config.PropertyPlaceholderConfigurer |
---|
parseStringValue, processProperties, resolvePlaceholder, resolveSystemProperty, setSearchSystemEnvironment, setSystemPropertiesMode, setSystemPropertiesModeName |
Methods inherited from class org.springframework.beans.factory.config.PlaceholderConfigurerSupport |
---|
doProcessProperties, setBeanFactory, setBeanName, setIgnoreUnresolvablePlaceholders, setNullValue, setPlaceholderPrefix, setPlaceholderSuffix, setValueSeparator |
Methods inherited from class org.springframework.beans.factory.config.PropertyResourceConfigurer |
---|
convertProperties, convertProperty, convertPropertyValue, getOrder, postProcessBeanFactory, setOrder |
Methods inherited from class org.springframework.core.io.support.PropertiesLoaderSupport |
---|
loadProperties, mergeProperties, setFileEncoding, setIgnoreResourceNotFound, setLocalOverride, setLocation, setLocations, setProperties, setPropertiesArray, setPropertiesPersister |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private boolean contextOverride
private boolean searchContextAttributes
private ServletContext servletContext
Constructor Detail |
---|
public ServletContextPropertyPlaceholderConfigurer()
Method Detail |
---|
public void setContextOverride(boolean contextOverride)
Note that system properties will still override ServletContext settings, if the system properties mode is set to "SYSTEM_PROPERTIES_MODE_OVERRIDE".
setSearchContextAttributes(boolean)
,
PropertyPlaceholderConfigurer.setSystemPropertiesModeName(java.lang.String)
,
PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE
public void setSearchContextAttributes(boolean searchContextAttributes)
If turned on, the configurer will look for a ServletContext attribute with
the same name as the placeholder, and use its stringified value if found.
Exposure of such ServletContext attributes can be used to dynamically override
init parameters defined in web.xml
, for example in a custom
context listener.
javax.servlet.ServletContext#getInitParameter(String)
,
javax.servlet.ServletContext#getAttribute(String)
public void setServletContext(ServletContext servletContext)
If not set, this configurer will simply not resolve placeholders against the ServletContext: It will effectively behave like a plain PropertyPlaceholderConfigurer in such a scenario.
setServletContext
in interface ServletContextAware
servletContext
- ServletContext object to be used by this objectInitializingBean.afterPropertiesSet()
,
ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)
protected java.lang.String resolvePlaceholder(java.lang.String placeholder, java.util.Properties props)
PropertyPlaceholderConfigurer
Subclasses can override this for customized placeholder-to-key mappings or custom resolution strategies, possibly just using the given properties as fallback.
Note that system properties will still be checked before respectively after this method is invoked, according to the system properties mode.
resolvePlaceholder
in class PropertyPlaceholderConfigurer
placeholder
- the placeholder to resolveprops
- the merged properties of this configurer
null
if nonePropertyPlaceholderConfigurer.setSystemPropertiesMode(int)
protected java.lang.String resolvePlaceholder(java.lang.String placeholder, ServletContext servletContext, boolean searchContextAttributes)
Default implementation checks ServletContext attributes before init parameters. Can be overridden to customize this behavior, potentially also applying specific naming patterns for parameters and/or attributes (instead of using the exact placeholder name).
placeholder
- the placeholder to resolveservletContext
- the ServletContext to checksearchContextAttributes
- whether to search for a matching
ServletContext attribute
javax.servlet.ServletContext#getInitParameter(String)
,
javax.servlet.ServletContext#getAttribute(String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |