WebSphere Application Server makes heavy use of variables in its configuration files. This is to make it easier to change your configuration. For example, if every reference to every file were a fully qualified, absolute reference, it would be difficult to administer WebSphere Application Server. There would be times when moving a file from one directory tree to another would require hundreds of configuration edits. WAS vairables represent any of the following
WAS_INSTALL_ROOTThe location of WebSphere Application Server binary filesUSER_INSTALL_ROOTAllows you to write scripts that can serve any userLOG_ROOTThe location of various logsAPP_INSTALL_ROOTThe location of exploded EAR filesDERBY_JDBC_DRIVER_PATHEnable you to write scripts that do not have to be changed if you ever move this driver to a different place in your file system
WAS_SERVER_NAMEEnables you to write a script that you can run against any server without knowing the server's name in advanceWAS_CELL_NAMEEnables you to write a script that you can run against any cell without knowing the server's name in advance
What would a script possibly do with any WebSphere Variable?
- Read an existing WebSphere Variable
- Change the value of an existing WebSphere Variable
- Create a new WebSphere Variable
What do you have to think about when you use any WebSphere Variable in a script?
- What is the name of the variable?
- What is the scope of the variable? Your choices are cell scope, node scope or server scope
- Do you want to change the value of the variable or just read the value of the variable?
To see WebSphere variables and their values:
- AdminTask.showVariables( "[ -scope " + someScope + " ]" )
- AdminTask.showVariables( "[ -scope " + someScope + " -variableName " + someVariableName +" ]" )
- someScope is case sensitive. someScope is supplied by the programmer and takes the form of
- "Cell=something" -- cell scope
- "Node=something" -- node scope
- "Node=something,Server=something" -- server scope
The AdminTask.showVariables() method examines the content of the variables.xml configuration file associated with the chosen scope. If there is no such file in the scope you choose, AdminTask.showVariables() throws an exception.
getVariablesInScope() contains code that finds all the variables in either
- Cell scope
- A given Node scope
- A given Server scope
The code that actually searches for the variables is the call to AdminTask.showVariables() near lines 21 and 26. Everything else converts the string that AdminTask.showVariables() returns into a Python Dictionary of variables and their values. The try block around these two lines traps the exception that AdminTask.showVariables() throws when there are no variables in the scope you request
|