last update: 10/21/2004 11:20:16

More about variables


The GettingStarted has provided an overview about how to use variables inside the configuration. Here are two more things that eases the use of variables and help you writing a platform independent configuration.

System properties

Since the latest release v2.3 the VariableManager can translate java system properties. These system properties are set by the JVM and are mostly platform dependent. The temp-directory for example differs for every operaring system. In order to build a platform independent configuration you can use these system properties. You need to put the sytem: keyword in front of the property name:
<property name="tmpdir" value="${system:java.io.tmpdir}"/>
After the keyword you have to put the name of the system propery. This example will set the tmpdir to the OS specific temp-directory.
You can use any system property.

Environment variables

Another way for writing platform indenpendet applications is the use of environment variables. This is an usual at least under Linux/Unix. You can set a home variable to your application. When you want to use an environment variable you have to put the env: keyword in front of the name. Here is a short example:
<property name="app_home" value="${env:MY_APP_HOME}"/>
This MYAPPHOME can be either "/usr/local/myapp" under Linux or "c:\myapp" under Windows. All you have to do is define such an environment variable and you can move your applications between different OS.


There is a demo that shows these examples located in the demo subdirectory.