org.springframework.beans.factory.config
Class PreferencesPlaceholderConfigurer
java.lang.Object
org.springframework.core.io.support.PropertiesLoaderSupport
org.springframework.beans.factory.config.PropertyResourceConfigurer
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer
- All Implemented Interfaces:
- BeanFactoryAware, BeanNameAware, BeanFactoryPostProcessor, InitializingBean, Ordered, PriorityOrdered
public class PreferencesPlaceholderConfigurer
- extends PropertyPlaceholderConfigurer
- implements InitializingBean
Subclass of PropertyPlaceholderConfigurer that supports JDK 1.4's
Preferences API (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.
- Since:
- 16.02.2004
- Author:
- Juergen Hoeller
- See Also:
setSystemTreePath(java.lang.String)
,
setUserTreePath(java.lang.String)
,
Preferences
Method Summary |
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. |
Methods inherited from class org.springframework.beans.factory.config.PropertyPlaceholderConfigurer |
parseStringValue, processProperties, resolvePlaceholder, resolveSystemProperty, setBeanFactory, setBeanName, setIgnoreUnresolvablePlaceholders, setNullValue, setPlaceholderPrefix, setPlaceholderSuffix, setSearchSystemEnvironment, setSystemPropertiesMode, setSystemPropertiesModeName, setValueSeparator |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
systemTreePath
private java.lang.String systemTreePath
userTreePath
private java.lang.String userTreePath
systemPrefs
private java.util.prefs.Preferences systemPrefs
userPrefs
private java.util.prefs.Preferences userPrefs
PreferencesPlaceholderConfigurer
public PreferencesPlaceholderConfigurer()
setSystemTreePath
public void setSystemTreePath(java.lang.String systemTreePath)
- Set the path in the system preferences tree to use for resolving
placeholders. Default is the root node.
setUserTreePath
public void setUserTreePath(java.lang.String userTreePath)
- Set the path in the system preferences tree to use for resolving
placeholders. Default is the root node.
afterPropertiesSet
public void afterPropertiesSet()
- This implementation eagerly fetches the Preferences instances
for the required system and user tree nodes.
- Specified by:
afterPropertiesSet
in interface InitializingBean
resolvePlaceholder
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.
- Overrides:
resolvePlaceholder
in class PropertyPlaceholderConfigurer
- Parameters:
placeholder
- the placeholder to resolveprops
- the merged properties of this configurer
- Returns:
- the resolved value, of
null
if none - See Also:
PropertyPlaceholderConfigurer.setSystemPropertiesMode(int)
resolvePlaceholder
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.
- Parameters:
path
- the preferences path (placeholder part before '/')key
- the preferences key (placeholder part after '/')preferences
- the Preferences to resolve against
- Returns:
- the value for the placeholder, or
null
if none found