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:
<globalVariable> <name>JmsProviderUrl</name> <value>tcp://localhost:7222</value> <deploymentSettable>true</deploymentSettable> <serviceSettable>false</serviceSettable> <type>String</type> <modTime>1282736878059</modTime> </globalVariable> <globalVariable> <name>JmsSslProviderUrl</name> <value>ssl://localhost:7243</value> <deploymentSettable>true</deploymentSettable> <serviceSettable>false</serviceSettable> <type>String</type> <modTime>1282736877974</modTime> </globalVariable> <globalVariable> <name>RemoteRvDaemon</name> <value></value> <deploymentSettable>true</deploymentSettable> <serviceSettable>false</serviceSettable> <type>String</type> <modTime>1282736878048</modTime> </globalVariable>
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:
<globalVariable> <name>JmsProviderUrl</name> <value>tcp://localhost:7222</value> <deploymentSettable>true</deploymentSettable> <serviceSettable>false</serviceSettable> <type>String</type> <modTime>1282736878059</modTime> </globalVariable>
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:
<repository xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns = "http://www.tibco.com/xmlns/repo/types/2002"> <globalVariables>
</globalVariables> </repository>
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:
<repository xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns = "http://www.tibco.com/xmlns/repo/types/2002"> <globalVariables>
<globalVariable> <name>JMS_Username</name> <value>User</value> <deploymentSettable>true</deploymentSettable> <serviceSettable>false</serviceSettable> <type>String</type> <modTime>1282736878069</modTime> </globalVariable> <globalVariable> <name>JMS_Password</name> <value>Password</value> <deploymentSettable>true</deploymentSettable> <serviceSettable>false</serviceSettable> <type>Password</type> <modTime>1282736878069</modTime> </globalVariable>
</globalVariables> </repository>
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:
Doesn’t work my friend. You will see the variables all nicely listed in the Global Variables tab and in the editor but when you go to test your project only the variables created using the editor will show when you breakpoint and check the process inputs tab. The variables created outside the editor will never show causing your tester to crap out due to null values. I have closed and reopened my project in the designer many times but to no avail, variables will not show. Using Tibco designer 5.6.2.5.
LikeLike
Hi Darren,
I have used this technique in several projects and it does work. I am using Designer 5.5.2.2.
One thing you can try to do is close the project before you start modifying the GVs.
Also Designer is known to be unstable, in general, and it can crap up the project when doing something as simple as debugging.
Also with Designer always remember to save your project and take a backup! I have had the Designer hanging up on me sometimes especially when using the Debugger.
I am also attaching a test project to the post, where the GVGroup Connections and all GVs within it were defined using the method I described. The project works fine.
Hope it helps!
– Azahar
LikeLike
Hi Azahar,
I think you are correct, this seems to be more of a possible bug in TIBCO when loading and debugging two projects at the same time. Seems that only the global variables from one of the projects is being used by both projects instead of each their own. Will post more when I fully investigate this…
Regards,
Darren
LikeLike
how to modify all global variables in tibco bt not from designer or administrator… do u change all gv values manually or any other process to change
LikeLike
how to modify all global variables in tibco bt not from designer or administrator… do u change all gv values manually or any other process to change…TCS Bangalore interview question
plz send reply to my id mr.orcut@gmail.com
LikeLike