spring-framework / org.springframework.beans.factory.config / PreferencesPlaceholderConfigurer

PreferencesPlaceholderConfigurer

open class PreferencesPlaceholderConfigurer : PropertyPlaceholderConfigurer, 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.

Author
Juergen Hoeller

Since
16.02.2004

See Also
#setSystemTreePath#setUserTreePathjava.util.prefs.Preferences

Constructors

<init>

PreferencesPlaceholderConfigurer()

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.

Inherited Properties

SYSTEM_PROPERTIES_MODE_FALLBACK

static val SYSTEM_PROPERTIES_MODE_FALLBACK: Int

Check system properties if not resolvable in the specified properties. This is the default.

SYSTEM_PROPERTIES_MODE_NEVER

static val SYSTEM_PROPERTIES_MODE_NEVER: Int

Never check system properties.

SYSTEM_PROPERTIES_MODE_OVERRIDE

static val SYSTEM_PROPERTIES_MODE_OVERRIDE: Int

Check system properties first, before trying the specified properties. This allows system properties to override any other property source.

Functions

afterPropertiesSet

open fun afterPropertiesSet(): Unit

This implementation eagerly fetches the Preferences instances for the required system and user tree nodes.

setSystemTreePath

open fun setSystemTreePath(systemTreePath: String): Unit

Set the path in the system preferences tree to use for resolving placeholders. Default is the root node.

setUserTreePath

open fun setUserTreePath(userTreePath: String): Unit

Set the path in the system preferences tree to use for resolving placeholders. Default is the root node.

Inherited Functions

setSearchSystemEnvironment

open fun setSearchSystemEnvironment(searchSystemEnvironment: Boolean): Unit

Set whether to search for a matching system environment variable if no matching system property has been found. Only applied when "systemPropertyMode" is active (i.e. "fallback" or "override"), right after checking JVM system properties.

Default is "true". Switch this setting off to never resolve placeholders against system environment variables. Note that it is generally recommended to pass external values in as JVM system properties: This can easily be achieved in a startup script, even for existing environment variables.

NOTE: Access to environment variables does not work on the Sun VM 1.4, where the corresponding System#getenv support was disabled - before it eventually got re-enabled for the Sun VM 1.5. Please upgrade to 1.5 (or higher) if you intend to rely on the environment variable support.

setSystemPropertiesMode

open fun setSystemPropertiesMode(systemPropertiesMode: Int): Unit

Set how to check system properties: as fallback, as override, or never. For example, will resolve ${user.dir} to the "user.dir" system property.

The default is "fallback": If not being able to resolve a placeholder with the specified properties, a system property will be tried. "override" will check for a system property first, before trying the specified properties. "never" will not check system properties at all.

setSystemPropertiesModeName

open fun setSystemPropertiesModeName(constantName: String): Unit

Set the system property mode by the name of the corresponding constant, e.g. "SYSTEM_PROPERTIES_MODE_OVERRIDE".