Variables

Variables are used to generate service connection points. They can save connection strings from difference sources. Variables can also help to find connections strings in configuration documents if their names or locations are configurable.

Declaration

Variables do not need to be declared first. Except predefined variables, other variables are defined at the first time they are assigned a value.

Naming

Variable names are case-sensitive. A variable name can be a string of any length that contains English letters, digits, underscore (_), or dot (.).

Value

A variable can contain multiple values. Each variable value must be a string value. When a variable is assigned with more than one value, the values are saved as an ordered list.

Predefined variables

Some variables are predefined to help with searching connection strings in command line or file system:

  • scp.type: The connection type or protocol of the trigger service connection point.
  • scp.ip: The IP address of the trigger service connection point.
  • scp.port: The listening port of the trigger service connection point.
  • scp.context: The context of the trigger service connection point.
  • process.name: A list of process names of discovering running software.
  • process.path: A list of process paths of discovering running software.
  • process.<process name>.path: A list of process paths with specified name of discovering running software. For example, variable process.tomcat.path saves the paths of all Tomcat processes belong to current discovering running software.

Note All process names are saved in lower case. On Windows, the “.exe” file extension for executable files is not needed.

Use

A variable can be used in a file name, file path, file content, property key, XPath, or regular expression. The syntax to use a variable is ${<Variable name>}. For example, part of the connection string might be the IP address(es) of the provider. To save the IP address(es) in the configuration document, you can define a variable named IP_ADDRESS and use it in the expression in this way: ${IP_ADDRESS}.

Note Variables that are used but are not assigned will be ignored or be treated as empty strings. Such a variable may cause an error during the discovery.

Scope

The scope of all variables are inside an <Application> element.

Group

Variables defined in the same element are grouped. For example, some variables are defined as the example below:

<CommandLine>
    <Regex expr="\s*(\S+)=\s*(\S+).*">
        <Variable name="name" group="1"/>
        <Variable name="value" group="2"/>
    </Regex>
    <SystemVariable name="oracle_home" environmentName="ORACLE_HOME"/>
    <SystemVariable name="tns_home" environmentName="TNS_ADMIN"/>
</CommandLine>

In this example, variable name and value are grouped. Variable oracle_home and tns_home are standalone variables.

When variables of the same group have more than one values, and the variables are used in the same element, they share the same iterator. Variables that are not in the same group use different iterators when the expression is being resolved.

For example, the following expression uses two variables (path and file) to express the full path, and each variable has multiple values.

<Path>${path}/${filename}</Path>

If the two variables are in the same variable group, this expression will be resolved to a string list as follows:

<path1>/<filename1>, <path2>/<filename2>, <path3>/<filename3> …

If the two variables are not in the same variable group, this expression will be resolved to the following:

<path1>/<filename1>, <path1>/<filename2>, <path1>/<filename3> …
<path2>/<filename1>, <path2>/<filename2>, <path2>/<filename3> …
<path3>/<filename1>, <path3>/<filename2>, <path3>/<filename3> …

Note A grouped variable should have the same number of values as the other variables in the same variable group. The only exception is that the variable has only one value.

Assignment

Configuration signature supports several different ways to assign one or more values to a variable:

  • Get value from the system environment variable: <SystemVariable>.
  • Get value from a property file by specified property key: <Property> or <PropertyVariable>.
  • Get values from an XML file by using XPath expression: <XPath> or <XPathVariable>.
  • Get values from a string by using regular expression: <Regex>. Can be embedded in other sources of variables.

Default Values

Variables can have default values. When the specified value is not found for a variable, the default value will be assigned. If the default value is not defined in this case, the signature processor ignores all ungrouped variables and assigns an empty string to grouped variables to make the lengths of their value lists consistent.

Note For embedded variables, if their parent does not match its condition or has no result, the whole block of variables will be ignored and the default value will not be assigned.