Project Tasks : Working with Global Variables

Working with Global Variables
Global variables provide an easy way to set defaults for use throughout your project. At deploy time, you can override default values as needed. When the project is deployed all occurrences of the global variable name are replaced with the provided global variable value.
For example, you could assign the value 7474 to the global variable RvDaemon. You can then use the variable in a Rendezvous Transport resource. You can also override the value at deploytime. This section explains how to add global variables, and how to use them in project fields at design time.
A project folder called defaultVars is exposed so that you can share the global variables using source control software. It is not used for other purposes.
Adding and Managing Global Variables
In a new Studio project no global variables are predefined. When you import a project from an earlier version of BusinessEvents, however, you see predefined global variables such as the following (as well as any others defined in the project).
To Add and Manage Global Variables
1.
2.
Select Project > Edit Global Variables.
You see the Global Variables view listing the variables available, if any.
3.
4.
To add a variable, click Add Variable and complete the fields.
Using Groups  Groups are used for organizing variables. Variable groups are especially useful if multiple developers share a project using a version control system. When referencing a variable that is in a group, use the complete path, for example %%mygroup/mysubgroup/myvariable%%.
You must add at least one variable to a group, or the group will not be saved. If you delete all global variables in a global variable group, the group itself is also automatically deleted.
5.
Save the resource. Groups and references to the defaultVars.substvar file appear in the defaultVars project folder.
Deployment settable
If checked, the variable is visible and settable when deploying using TIBCO Administrator. The values set at that time are saved in the project that TIBCO Administrator creates from the provided EAR file.
If the checkbox is not checked, the variable is not visible in TIBCO Administrator. It is checked by default.
If this box is checked, the value of the global variable can be overwritten by defining the same variable in a properties file. At runtime, the value in properties file overrides the value set using the Global Variable editor.
For example, in the Global Variables editor you define a property jmsHostName and give it the value test-dt. At deploy time you enter a different value in the properties file, for example, jmsHostName=prod-dt, and you reference that file when deploying using the -p option.
For use when deploying with TIBCO Administrator. Used only when Deployment Settable is also checked (ignored otherwise). Used to include or exclude service-level global variables when building the EAR file.
If checked, the variable is included when the Include all service level global variables option is selected when building the enterprise archive file.
In TIBCO Administrator, a service corresponds to one PAR (for TIBCO ActiveMatrix BusinessWorks) or one agent (for BusinessEvents).
Values set at the service or service instance level are passed to the engine at runtime in the format tibco.clientVar.VariableName=value.
Optional. For String and Integer types, allows you to provide a range of allowed values. The constraint field for Strings is an enumeration, for example, one, two, three. The constraint field for Integers is for a range, for example, 1-100.
Using Global Variables
To Use Global Variables in BusinessEvents Studio Project Fields
To use a global variable as the value for a project setting, drag it from the list of variables into the text box for the setting, or enter it manually using the syntax %%Variable_Group/Variable_Name%%. You must include the global variable group hierarchy, if one exists. For example, to use a caching scheme global variable in a File Path field, you might enter %%Cache/CachingSchemeLoc%%.
To Use Global Variables in the Rule Editor
To use a global variable in the rule editor, use one of the System.getGlobalVariableAs* functions. For example:
System.getGlobalVariableAsString("myvars/Hostname", "Localhost")
Where myvars/Hostname is the name of the variable group and variable, and Localhost is an optional literal value to use if the variable is not found.
To Use Global Variables in the CDD
You can add global variable override properties in the Cluster Deployment Descriptor editor. Add properties called tibco.clientVar.GVName and provide the override value as the property value. Place the property at the appropriate level in the CDD: cluster, processing unit, or agent class.
To Use Global Variables when Deploying at the Command Line.
You can also override variable values when starting an engine directly at the command line. You can pass the overrides directly, using the --propVar option, or in a file, referenced using the -p option.