5.5. Using Property Value Substitution in the Configuration

In an environment where you have more than one OpenIDM instance, you might require a configuration that is similar, but not identical, across the different OpenIDM hosts. OpenIDM supports variable replacement in its configuration which means that you can modify the effective configuration according to the requirements of a specific environment or OpenIDM instance.

Property substitution enables you to achieve the following:

  • Define a configuration that is specific to a single OpenIDM instance, for example, setting the location of the keystore on a particular host.

  • Define a configuration whose parameters vary between different environments, for example, the URLs and passwords for test, development, and production environments.

  • Disable certain capabilities on specific nodes. For example, you might want to disable the workflow engine on specific instances.

When OpenIDM starts up, it combines the system configuration, which might contain specific environment variables, with the defined OpenIDM configuration properties. This combination makes up the effective configuration for that OpenIDM instance. By varying the environment properties, you can change specific configuration items that vary between OpenIDM instances or environments.

Property references are contained within the construct &{ }. When such references are found, OpenIDM replaces them with the appropriate property value, defined in the boot.properties file.

Example 5.1. 

The following example defines two separate OpenIDM environments - a development environment and a production environment. You can specify the environment at startup time and, depending on the environment, the database URL is set accordingly.

The environments are defined by adding the following lines to the conf/boot.properties file:

   PROD.location=production
   DEV.location=development
   

The database URL is then specified as follows in the repo.orientdb.json file:

    {
    "dbUrl" : "local:./db/&{&{environment}.location}-openidm",
    "user" : "admin",
    "poolMinSize" : 5,
    "poolMaxSize" : 20,
    ...
    }
   

The effective database URL is determined by setting the OPENIDM_OPTS environment variable when you start OpenIDM. To use the production environment, start OpenIDM as follows:

   $ export OPENIDM_OPTS="-Xmx1024m -Denvironment=PROD"
   $ ./startup.sh
   

To use the development environment, start OpenIDM as follows:

   $ export OPENIDM_OPTS="-Xmx1024m -Denvironment=DEV"
   $ ./startup.sh