Following the overview is an optional constants section. Each constant takes the form:
The name is a valid variable name; the expression is a literal or any expression that depends only on other constants previously declared in the pattern. Named constants are available in the subsequent trigger, body and removal sections. Constant values are not available outside the pattern in which they are declared.
Constants should be used for values that are likely to be changed by pattern authors, such as regular expressions to extract versions from paths, and so on. They should not be used for values that are expected to be changed by normal users of the pattern — in those situations, a Pattern Configuration block should be used.
For example, this defines two regular expressions to be used in the pattern body:
Referencing pattern constants
From TPL version 1.5 (BMC Atrium Discovery 8.2) it is possible to reference constants defined in one pattern from other patterns.
In the first pattern
Tomcat 1.0 the constant
Tomcat.si_type is defined.
In the second code sample, the
Tomcat 1.0 pattern is imported and in the
ExtendedTomcat 1.0 pattern the
Tomcat.si_type is referenced.