|
|
Version of Designer used: 5.5.2.2
Global Variables (GVs) are one of the most important bits of any BusinessWorks project. Every project will have at least one set of GVs, usually to store certain settings centrally. GVs also allow those settings to be changed on a running application without having to re-archive and re-deploy it.
A common usage scenario (which I will be using as an example as well) for GVs is to store connection settings for the EMS server. Basic set of connection settings for say a JMS Connection resource would be the Username and Password information and the JNDI information.
As it is very important to structure the GVs properly for easy reference and maintainability you should make good use of Groups. A common way of structuring GVs is to use the location path as a group.
For example if your JMS Connection resource is in /MyProject/Connections/JMS/ folder then you would create three groups. A main group for all the project GVs called MyProject, below that a sub-group for all Connections in your project and below that a group for all JMS connections and so on.
But if you have tried to use the GV editor in Designer and have been frustrated with forever expanding and collapsing nodes, re-sizing the window and not being able to copy-paste stuff then you will know what a nightmare it is to create complex group hierarchies. Don’t you wish you could just edit an XML file and create those GVs instead of using the built-in GV editor in Designer.
Fear not though, there is a quicker and easier way of creating and edition GVs (otherwise no point in writing this post
Lets start with a blank canvas so as to say. Open up the Designer and navigate to the Global Variables tab (see image below). Click the yellow pencil button to bring up the dreaded built-in GV editor.
Let us say we want to create a complex hierarchy of groups and values but we want to do it without getting frustrated with the built-in GV editor. It is possible to achieve this using the Windows Explorer (or the Linux equivalent) along with a text-editor (even Notepad will do but I prefer Notepad++ as it has XML support).
Basic Concept
Before we start the editing process it is important to understand how the GVs are stored in a project. One would have thought there would be a file with the GV hierarchy and values which we could edit. That thought is partially correct.
The main thing to understand is that every GV Group is a folder within the Global Variable root folder (more on this later). Furthermore every GV is an entry in a simple text file within the folder of the Group it belongs to.
Locate the Global Variable Root Folder
Open up your Windows Explorer and navigate to your TIBCO Designer Workspace folder. There navigate to the project for which you want to create GVs. Within the project folder there should be a folder called ‘defaultVars’. This is the ‘root’ folder for your global variables.
In the example the project name is WebServiceTest and the path is: [TIBCO Workspace Folder]\WebServiceTest\defaultVars
DefaultVars.substvar File
Within the ‘defaultVars’ folder you will find a file named defaultVars.substvar. This file can be opened in any text-editor and it contains all GVs belonging to the ‘root’ Group.
If you open this file in a text-editor you will find that it contains XML data. For the above set of GVs (see image) in the ‘root’ Group you will see entries like:
JmsProviderUrl
tcp://localhost:7222
true
false
String
1282736878059
JmsSslProviderUrl
ssl://localhost:7243
true
false
String
1282736877974
RemoteRvDaemon
true
false
String
1282736878048
From the above listing we can see that each GV has its own globalVariable element. There are several child elements present for each global variable:
Name - is the ‘name’ of the GV which is also displayed in the Global Variable tree (see figure above).
Value - is the actual value of the GV.
DeploymentSettable - GV can be set during deployment.
ServiceSettable - GV is settable at per service level. Used for TIBCO Adapter archives.
Type – Data type of the GV. Possible data types: String, Integer, Password and Boolean.
ModTime - Time GV was modified.
So the root variable JmsProviderUrl is represented as:
JmsProviderUrl
tcp://localhost:7222
true
false
String
1282736878059
Example Now if we want to create a new set of GVs for a JMS connection with the location WebServiceTest/Connections/JMS then we need to first create the folder structure within the root folder which will give us the corresponding Groups in the Global Variables tab. The folder structure will now look like below: Next we need to add some GVs to the JMS group. To do this go down to the JMS sub-folder and in there create a defaultVars.substvar to store the GVs. Make sure the extension of the file is .substvar. Next open this file in a text-editor and add the following tags:
All variables will be defined within the globalVariables tag.
Next we create two GVs one for storing the EMS username (JMS_Username) and one for storing the password (JMS_Password) as below:
JMS_Username
User
true
false
String
1282736878069
JMS_Password
Password
true
false
Password
1282736878069
Save and close the file. Then close and reopen the project in Designer (required to refresh the Global Variable tab).
After reopening the project if you go to the GV tab you will see the following:
As you can see the two GVs we created in the file are now ready for use. Also notice each of the folders we created within the defaultVars root folder is shown as a Group.
Using this method you can also copy-paste GVs for things like JMS Queue Receiver and Senders to create separate set of GVs for different processes and/or services.
Example project: http://www.fisheyefocus.com/GVTest.zip
Overview with the created GVs on the left hand side and the JMS connection using one of the GVs on the right hand side:
The project running:
Categories: None
The words you entered did not match the given text. Please try again.









Oops!
Oops, you forgot something.