|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.core.env.AbstractPropertyResolver
public abstract class AbstractPropertyResolver
Abstract base class for resolving properties against any underlying source.
| Field Summary | |
|---|---|
protected ConfigurableConversionService |
conversionService
|
protected Log |
logger
|
| Constructor Summary | |
|---|---|
AbstractPropertyResolver()
|
|
| Method Summary | ||
|---|---|---|
ConfigurableConversionService |
getConversionService()
|
|
|
getProperty(String key,
Class<T> targetType,
T defaultValue)
Return the property value associated with the given key, or defaultValue if the key cannot be resolved. |
|
String |
getProperty(String key,
String defaultValue)
Return the property value associated with the given key, or defaultValue if the key cannot be resolved. |
|
String |
getRequiredProperty(String key)
Return the property value associated with the given key, converted to the given targetType (never null). |
|
|
getRequiredProperty(String key,
Class<T> valueType)
Return the property value associated with the given key, converted to the given targetType (never null). |
|
String |
resolvePlaceholders(String text)
Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by PropertyResolver.getProperty(java.lang.String). |
|
String |
resolveRequiredPlaceholders(String text)
Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by PropertyResolver.getProperty(java.lang.String). |
|
void |
setConversionService(ConfigurableConversionService conversionService)
Set the ConfigurableConversionService to be used when performing type
conversions on properties. |
|
void |
setPlaceholderPrefix(String placeholderPrefix)
Set the prefix that placeholders replaced by this resolver must begin with. |
|
void |
setPlaceholderSuffix(String placeholderSuffix)
Set the suffix that placeholders replaced by this resolver must end with. |
|
void |
setRequiredProperties(String... requiredProperties)
Specify which properties must be present, to be verified by ConfigurablePropertyResolver.validateRequiredProperties(). |
|
void |
setValueSeparator(String valueSeparator)
Specify the separating character between the placeholders replaced by this resolver and their associated default value, or null if no such
special character should be processed as a value separator. |
|
void |
validateRequiredProperties()
Validate that each of the properties specified by ConfigurablePropertyResolver.setRequiredProperties(java.lang.String...) is present and resolves to a
non-null value. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.springframework.core.env.PropertyResolver |
|---|
containsProperty, getProperty, getProperty, getPropertyAsClass |
| Field Detail |
|---|
protected final Log logger
protected ConfigurableConversionService conversionService
| Constructor Detail |
|---|
public AbstractPropertyResolver()
| Method Detail |
|---|
public ConfigurableConversionService getConversionService()
getConversionService in interface ConfigurablePropertyResolverConfigurableConversionService used when performing type
conversions on properties.
The configurable nature of the returned conversion service allows for
the convenient addition and removal of individual Converter instances:
ConfigurableConversionService cs = env.getConversionService(); cs.addConverter(new FooConverter());
PropertyResolver.getProperty(String, Class),
ConverterRegistry.addConverter(org.springframework.core.convert.converter.Converter, ?>)public void setConversionService(ConfigurableConversionService conversionService)
ConfigurablePropertyResolverConfigurableConversionService to be used when performing type
conversions on properties.
Note: as an alternative to fully replacing the ConversionService, consider adding or removing individual Converter
instances by drilling into ConfigurablePropertyResolver.getConversionService() and calling methods
such as #addConverter.
setConversionService in interface ConfigurablePropertyResolverPropertyResolver.getProperty(String, Class),
ConfigurablePropertyResolver.getConversionService(),
ConverterRegistry.addConverter(org.springframework.core.convert.converter.Converter, ?>)
public String getProperty(String key,
String defaultValue)
PropertyResolverdefaultValue if the key cannot be resolved.
getProperty in interface PropertyResolverkey - the property name to resolvedefaultValue - the default value to return if no value is foundPropertyResolver.getRequiredProperty(String),
PropertyResolver.getProperty(String, Class)
public <T> T getProperty(String key,
Class<T> targetType,
T defaultValue)
PropertyResolverdefaultValue if the key cannot be resolved.
getProperty in interface PropertyResolverdefaultValue - the default value to return if no value is foundPropertyResolver.getRequiredProperty(String, Class)public void setRequiredProperties(String... requiredProperties)
ConfigurablePropertyResolverConfigurablePropertyResolver.validateRequiredProperties().
setRequiredProperties in interface ConfigurablePropertyResolverpublic void validateRequiredProperties()
ConfigurablePropertyResolverConfigurablePropertyResolver.setRequiredProperties(java.lang.String...) is present and resolves to a
non-null value.
validateRequiredProperties in interface ConfigurablePropertyResolver
public String getRequiredProperty(String key)
throws IllegalStateException
PropertyResolvernull).
getRequiredProperty in interface PropertyResolverIllegalStateException - if the key cannot be resolvedPropertyResolver.getRequiredProperty(String, Class)
public <T> T getRequiredProperty(String key,
Class<T> valueType)
throws IllegalStateException
PropertyResolvernull).
getRequiredProperty in interface PropertyResolverIllegalStateException - if the given key cannot be resolvedpublic void setPlaceholderPrefix(String placeholderPrefix)
setPlaceholderPrefix in interface ConfigurablePropertyResolverSystemPropertyUtils.PLACEHOLDER_PREFIXpublic void setPlaceholderSuffix(String placeholderSuffix)
setPlaceholderSuffix in interface ConfigurablePropertyResolverSystemPropertyUtils.PLACEHOLDER_SUFFIXpublic void setValueSeparator(String valueSeparator)
null if no such
special character should be processed as a value separator. The default is ":".
setValueSeparator in interface ConfigurablePropertyResolverSystemPropertyUtils.VALUE_SEPARATORpublic String resolvePlaceholders(String text)
PropertyResolverPropertyResolver.getProperty(java.lang.String). Unresolvable placeholders with
no default value are ignored and passed through unchanged.
resolvePlaceholders in interface PropertyResolvertext - the String to resolve
null)PropertyResolver.resolveRequiredPlaceholders(java.lang.String),
SystemPropertyUtils.resolvePlaceholders(String)
public String resolveRequiredPlaceholders(String text)
throws IllegalArgumentException
PropertyResolverPropertyResolver.getProperty(java.lang.String). Unresolvable placeholders with
no default value will cause an IllegalArgumentException to be thrown.
resolveRequiredPlaceholders in interface PropertyResolvernull)
IllegalArgumentException - if given text is nullSystemPropertyUtils.resolvePlaceholders(String, boolean)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||