Artwork implying World Wide Web Architecture

Display WebSphere Application Server Variables

Part of the WebSphere Application Server v7.x Administration Series Series
Most recently modified on 2008-07-24
Back to home page Back to articles page WAS architecture articles page Script articles page .
See also these related articles:
One Line Scripts

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

File Location Meaning
WAS_INSTALL_ROOT The location of WebSphere Application Server binary files
USER_INSTALL_ROOT Allows you to write scripts that can serve any user
LOG_ROOT The location of various logs
APP_INSTALL_ROOT The location of exploded EAR files
DERBY_JDBC_DRIVER_PATH Enable 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
Useful Name Meaning
WAS_SERVER_NAME Enables you to write a script that you can run against any server without knowing the server's name in advance
WAS_CELL_NAME Enables 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?

  1. Read an existing WebSphere Variable
  2. Change the value of an existing WebSphere Variable
  3. Create a new WebSphere Variable

What do you have to think about when you use any WebSphere Variable in a script?

  1. What is the name of the variable?
  2. What is the scope of the variable? Your choices are cell scope, node scope or server scope
  3. 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

Arthur Kevin McGrath

Bio:

The author is an engineer with the consulting firm, Contract Engineers. He has consulted and lectured extensively since 1987 about the infrastructure that makes electronic commerce possible. His publications include Leading Practices for WebSphere Dynamic Process Edition V6.2 (SG24-7776-00) and Websphere Application Server Administration Using Jython (ISBN 0137009526), the definitive book on WAS scripting.

Photo of the author
To schedule a speaker at your location, write speakers@edu4eng.com
To inquire about consulting for your company, write consultants@edu4eng.com
To inquire about training for your company, write training@edu4eng.com