Home
Categories
Dictionary
Glossary
Download
Project Details
Changes Log
What Links Here
FAQ
License

Environment variables declarations



Environment variables can be declared in the configuration, and reused in most of the configuration files (for example file paths).

Getting the value of environment variables

A system environment variable is declared by the env element. This element can have two attributes:
  • key: (mandatory) the name of the system environment variable
  • default: (optional) the default value of the variable if the environment variable does not exist


For example:
      <env key="APPLIS" />
The value of the system environment variable will be used in most of the configuration files with the ${variable_name} pattern.

For example:
      <files>
         <env key="APPLIS" />
      ...
         <file url="config/${APPLIS}" />
      </files>

Setting the value of environment variables

It is possible to set the value for an environment variable, with the setenv element. This element can have these attributes:
  • key: (mandatory) the name of the system environment variable
  • value: (mandatory) the value of the variable
  • type: (optional) "default" by default, or "url" if the environment variable represents an URL. In this case the environment variable will always be set as the absolute path relative to the filelist
  • overwrite: (optional) true if it is allowed to overwrite the current value of the environment variable if it already exists
For example:
      <files>
         <setenv key="APPLIS" value="applications.xml" />
      </files>

Examples

Basic Example

      <files>
         <env key="PROPERTIES" />
         <confProperty key="applis" value="applications.xml" />
         <file url="config/${applis}" />
         <file url="${services}" />
         <file url="types.xml" />
         <file url="${PROPERTIES}" />
      </files>
which can be called by:
      set PROPERTIES=properties.xml
      java -jar protoFramework.jar -config=filelist.xml

Another example

      <files>
         <setenv key="MYJSONFILE" type="url" value="myFile.json" />
         <file url="applis.xml" />
         <file url="services.xml" />
         <file url="types.xml" />
      </files>
which can be called by:
      java -jar protoFramework.jar -config=filelist.xml
In that case for example if one of the modules is a Python module and it uses the MYJSONFILE environment variable, we will be sure that the absolute path of the file will be set rather than the path relative to the filelist.

See also


Categories: config

Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence