Example syntax for the <systemproperty> element

The following example illustrates how to set the server environment using the <systemproperty> element of the <registry> element in config.xml.

<registry roles="…" >
  <systemproperty name="env" value="my.env" default="production"/>
</registry>

Notice that the defined <systemproperty> element:

  • Redefines the name of the env property to be my.env. Thus, in places in which you formerly used env, you now use my.env. For example, -Denv becomes -Dmy.env.
  • Sets a default value (production) for the system property.

To use this system property, you specify its value as a -D JVM option at server startup. The option syntax varies by server type.

QuickStart (Jetty)

-Dmy.env=…

Tomcat

-Dgw.pc.my.env=…

The value of my.env is immutable while the server is running.

PolicyCenter determines the value of the redefined env system property in the following manner, using -Dmy.env (on Jetty) as an example:

  • If you specify the -Dmy.env=test JVM option at the command prompt at server startup, PolicyCenter sets the value of env to test.
  • If you do not specify a -Dmy.env option at server start, PolicyCenter sets env to the value of default that you specified in the systemproperty, in this example, production.
  • If you do not set the value of my.env either through a default registry property or with a JVM option, PolicyCenter sets the value of the env property to null.
PolicyCenter ignores any attempt to set the environment property through the command prompt if you have previously defined that property using a <systemproperty> element. For example, suppose that you set the following <registry> element in config.xml:
  • <systemproperty name="env" value="my.env" default="standalone" />

Then, at server startup, you specify a -Denv="test" JVM option. PolicyCenter ignores any -Denv option that you specify on the command prompt and sets the env value to standalone.