public class PreferencesPlaceholderConfigurer extends PropertyPlaceholderConfigurer implements InitializingBean
java.util.prefs
).
Tries to resolve placeholders as keys first in the user preferences, then in the system preferences, then in this configurer's properties. Thus, behaves like PropertyPlaceholderConfigurer if no corresponding preferences defined.
Supports custom paths for the system and user preferences trees. Also supports custom paths specified in placeholders ("myPath/myPlaceholderKey"). Uses the respective root node if not specified.
setSystemTreePath(java.lang.String)
,
setUserTreePath(java.lang.String)
,
Preferences
Modifier and Type | Field and Description |
---|---|
private java.util.prefs.Preferences |
systemPrefs |
private java.lang.String |
systemTreePath |
private java.util.prefs.Preferences |
userPrefs |
private java.lang.String |
userTreePath |
SYSTEM_PROPERTIES_MODE_FALLBACK, SYSTEM_PROPERTIES_MODE_NEVER, SYSTEM_PROPERTIES_MODE_OVERRIDE
DEFAULT_PLACEHOLDER_PREFIX, DEFAULT_PLACEHOLDER_SUFFIX, DEFAULT_VALUE_SEPARATOR, ignoreUnresolvablePlaceholders, nullValue, placeholderPrefix, placeholderSuffix, valueSeparator
localOverride, localProperties, logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
PreferencesPlaceholderConfigurer() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
This implementation eagerly fetches the Preferences instances
for the required system and user tree nodes.
|
protected java.lang.String |
resolvePlaceholder(java.lang.String placeholder,
java.util.Properties props)
This implementation tries to resolve placeholders as keys first
in the user preferences, then in the system preferences, then in
the passed-in properties.
|
protected java.lang.String |
resolvePlaceholder(java.lang.String path,
java.lang.String key,
java.util.prefs.Preferences preferences)
Resolve the given path and key against the given Preferences.
|
void |
setSystemTreePath(java.lang.String systemTreePath)
Set the path in the system preferences tree to use for resolving
placeholders.
|
void |
setUserTreePath(java.lang.String userTreePath)
Set the path in the system preferences tree to use for resolving
placeholders.
|
parseStringValue, processProperties, resolvePlaceholder, resolveSystemProperty, setSearchSystemEnvironment, setSystemPropertiesMode, setSystemPropertiesModeName
doProcessProperties, setBeanFactory, setBeanName, setIgnoreUnresolvablePlaceholders, setNullValue, setPlaceholderPrefix, setPlaceholderSuffix, setValueSeparator
convertProperties, convertProperty, convertPropertyValue, getOrder, postProcessBeanFactory, setOrder
loadProperties, mergeProperties, setFileEncoding, setIgnoreResourceNotFound, setLocalOverride, setLocation, setLocations, setProperties, setPropertiesArray, setPropertiesPersister
private java.lang.String systemTreePath
private java.lang.String userTreePath
private java.util.prefs.Preferences systemPrefs
private java.util.prefs.Preferences userPrefs
public void setSystemTreePath(java.lang.String systemTreePath)
public void setUserTreePath(java.lang.String userTreePath)
public void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
protected java.lang.String resolvePlaceholder(java.lang.String placeholder, java.util.Properties props)
resolvePlaceholder
in class PropertyPlaceholderConfigurer
placeholder
- the placeholder to resolveprops
- the merged properties of this configurernull
if nonePropertyPlaceholderConfigurer.setSystemPropertiesMode(int)
protected java.lang.String resolvePlaceholder(java.lang.String path, java.lang.String key, java.util.prefs.Preferences preferences)
path
- the preferences path (placeholder part before '/')key
- the preferences key (placeholder part after '/')preferences
- the Preferences to resolve againstnull
if none found