Top Description Fields Constructors Methods
org.springframework.core.env

public Class PropertySourcesPropertyResolver

extends AbstractPropertyResolver
Class Inheritance
Imports
org.springframework.lang.Nullable

PropertyResolver implementation that resolves property values against an underlying set of PropertySources.
Authors
Chris Beams, Juergen Hoeller
Since
3.1
See Also
PropertySource, PropertySources, AbstractEnvironment

Field Summary

Modifier and TypeField and Description
private final PropertySources
Inherited from org.springframework.core.env.AbstractPropertyResolver:
logger

Constructor Summary

AccessConstructor and Description
public
PropertySourcesPropertyResolver(PropertySources
the set of PropertySource objects to use
propertySources
)

Create a new resolver against the given property sources.

Method Summary

Modifier and TypeMethod and Description
public boolean
containsProperty(String key)

Overrides org.springframework.core.env.AbstractPropertyResolver.containsProperty.

Implements org.springframework.core.env.PropertyResolver.containsProperty.

Return whether the given property key is available for resolution, i.e. if the value for the given key is not null.

public String
getProperty(String
the property name to resolve
key
)

Overrides org.springframework.core.env.AbstractPropertyResolver.getProperty.

Implements org.springframework.core.env.PropertyResolver.getProperty.

Return the property value associated with the given key, or null if the key cannot be resolved.

public <T> T
getProperty(String
the property name to resolve
key
,
Class<T>
the expected type of the property value
targetValueType
)

Implements org.springframework.core.env.PropertyResolver.getProperty.

Return the property value associated with the given key, or null if the key cannot be resolved.

protected <T> T
getProperty(String
the property name to resolve
key
,
Class<T>
the expected type of the property value
targetValueType
,
boolean
the default value to return if no value is found
resolveNestedPlaceholders
)

Overrides org.springframework.core.env.AbstractPropertyResolver.getProperty.

Implements org.springframework.core.env.PropertyResolver.getProperty.

Return the property value associated with the given key, or defaultValue if the key cannot be resolved.

protected String
getPropertyAsRawString(String
the property name to resolve
key
)

Implements abstract org.springframework.core.env.AbstractPropertyResolver.getPropertyAsRawString.

Retrieve the specified property as a raw String, i.e. without resolution of nested placeholders.

protected void
logKeyFound(String
the key found
key
,
PropertySource<?>
the PropertySource that the key has been found in
propertySource
,
Object
the corresponding value
value
)

Log the given key as found in the given PropertySource, resulting in the given value.

Inherited from org.springframework.core.env.AbstractPropertyResolver:
convertValueIfNecessarygetConversionServicegetPropertygetRequiredPropertygetRequiredPropertyresolveNestedPlaceholdersresolvePlaceholdersresolveRequiredPlaceholderssetConversionServicesetIgnoreUnresolvableNestedPlaceholderssetPlaceholderPrefixsetPlaceholderSuffixsetRequiredPropertiessetValueSeparatorvalidateRequiredProperties

Field Detail

propertySourcesback to summary
private final PropertySources propertySources
Annotations
@Nullable

Constructor Detail

PropertySourcesPropertyResolverback to summary
public PropertySourcesPropertyResolver(PropertySources propertySources)

Create a new resolver against the given property sources.

Parameters
propertySources:PropertySources

the set of PropertySource objects to use

Method Detail

containsPropertyback to summary
public boolean containsProperty(String key)

Overrides org.springframework.core.env.AbstractPropertyResolver.containsProperty.

Implements org.springframework.core.env.PropertyResolver.containsProperty.

Doc from org.springframework.core.env.PropertyResolver.containsProperty.

Return whether the given property key is available for resolution, i.e. if the value for the given key is not null.

Annotations
@Override
getPropertyback to summary
public String getProperty(String key)

Overrides org.springframework.core.env.AbstractPropertyResolver.getProperty.

Implements org.springframework.core.env.PropertyResolver.getProperty.

Doc from org.springframework.core.env.PropertyResolver.getProperty.

Return the property value associated with the given key, or null if the key cannot be resolved.

Parameters
key:String

the property name to resolve

Annotations
@Override
@Nullable
getPropertyback to summary
public <T> T getProperty(String key, Class<T> targetValueType)

Implements org.springframework.core.env.PropertyResolver.getProperty.

Doc from org.springframework.core.env.PropertyResolver.getProperty.

Return the property value associated with the given key, or null if the key cannot be resolved.

Parameters
key:String

the property name to resolve

targetValueType:Class<T>

the expected type of the property value

Annotations
@Override
@Nullable
getPropertyback to summary
protected <T> T getProperty(String key, Class<T> targetValueType, boolean resolveNestedPlaceholders)

Overrides org.springframework.core.env.AbstractPropertyResolver.getProperty.

Implements org.springframework.core.env.PropertyResolver.getProperty.

Doc from org.springframework.core.env.PropertyResolver.getProperty.

Return the property value associated with the given key, or defaultValue if the key cannot be resolved.

Parameters
key:String

the property name to resolve

targetValueType:Class<T>

the expected type of the property value

resolveNestedPlaceholders:boolean

the default value to return if no value is found

Annotations
@Nullable
getPropertyAsRawStringback to summary
protected String getPropertyAsRawString(String key)

Implements abstract org.springframework.core.env.AbstractPropertyResolver.getPropertyAsRawString.

Doc from org.springframework.core.env.AbstractPropertyResolver.getPropertyAsRawString.

Retrieve the specified property as a raw String, i.e. without resolution of nested placeholders.

Parameters
key:String

the property name to resolve

Returns:String

the property value or null if none found

Annotations
@Override
@Nullable
logKeyFoundback to summary
protected void logKeyFound(String key, PropertySource<?> propertySource, Object value)

Log the given key as found in the given PropertySource, resulting in the given value.

The default implementation writes a debug log message with key and source. As of 4.3.3, this does not log the value anymore in order to avoid accidental logging of sensitive settings. Subclasses may override this method to change the log level and/or log message, including the property's value if desired.

Parameters
key:String

the key found

propertySource:PropertySource<?>

the PropertySource that the key has been found in

value:Object

the corresponding value

Since
4.3.1