Previous Topic

Next Topic

Book Contents

Book Index

Parametrization of properties (.prs) files

It is important for the user to be able to provide generic property values via default.prs and all other prs files loaded. This abstraction allows more flexibility and reusability than using a raw values.

An option is provided to use parameters in prs files, which will be replaced on framework startup with their values. Supported sources of parameter lookup are:

In order to use this functionality, following syntax is introduced in prs files:

key=*${<parameter>}*

Values may have multiple parameters specified. On framework startup, each parameter will be replaced with its value(either an environment variable or a system property), if possible.

If there is no possible replacement, property value will be used as it is.

This syntax does not apply for property keys.

For more information refer to Apache API.

Examples

Some examples of usage in prs files are provided as follow.

Prefixes and suffixes remain unmodified:

B=X

A=prefix${B}suffix

Property A has value prefixXsuffix.

Multiple parameters may be used:

B=b

C=c

A=${B}${C}

Property A has value bc.

Order does not matter. This works as well with different prs files:

A=${B}${C}

B=b

C=c

Property A has value bc.

Environment variables are taken with priority over system properties, in case of overlap. Properties, that are not specified in prs files are also looked up.

X=${JAVA_HOME}

Y=${java.vm.name}

Z=${java.vm.version}

Property X has value, which is usually the path to JVM distribution package, properties Y and Z correspond to the JVM name and version.

Complex dependencies are supported.

A=${B}

B=${C}

C=test

Property A has value test.

Cyclic dependencies are not supported. When such dependency is detected, a warning is logged and property is discarded.

X=not.valid${X}

A=${B}

B=${A}

C=${D}

D=${E}

E=${C}

All these are invalid.