Creating, editing, and deleting WebSphere variables
You can use WebSphere variables to provide settings for any of the string data type attributes that are contained in the product configuration files.
Before you begin
Because applications cannot directly access WebSphere variables, if you define a WebSphere variable inside of an application, an error message, such as "Unknown variable," is returned. If you must reference a WebSphere variable from within an application, include the following method in the application to expand the string that uses the WebSphere variable.
避免困難: Expanding WebSphere variables requires you to have
administrative privileges.gotchaprivate String expandVariable(String s) throws
javax.management.JMException {
com.ibm.websphere.management.AdminService as =
com.ibm.websphere.management.AdminServiceFactory.getAdminService
();
String server = as.getProcessName();
java.util.Set result = as.queryNames(new javax.management.ObjectName("*:*,type=AdminOperations,process="
+ server), null);
return (String)as.invoke((javax.management.ObjectName)
result.iterator().next(),"expandVariable",new Object[]
{"${"+s+"}"}, new String[] {"java.lang.String"});
- Using
Jacl:
set mbean [$AdminControl completeObjectName WebSphere:*,type=AdminOperations] $AdminControl invoke $mbean expandVariable {{"${APP_INSTALL_ROOT}"}} - Using
Jython:
AdminOperations = AdminControl.completeObjectName('WebSphere:*,type=AdminOperations') print AdminControl.invoke(AdminOperations, 'expandVariable', '${APP_INSTALL_ROOT}')
About this task
WebSphere variables are usually used to specify file paths. The "Variable settings" topic supplies further details about specifying variables and highlights further details about product components that use them.
- Product path names, such as JAVA_HOME, and APP_INSTALL_ROOT.
- Certain customization values.
The variable scoping mechanism for WebSphere variables enables you to define a variable at the node level, as well as at the server level. This mechanism enables you to specify a setting for all of the servers in a node, cluster, or cell, instead of individually specifying the setting for each server.
To define a new variable, change the value of an existing variable, or delete an existing variable complete the following steps, as appropriate.
![[AIX Solaris HP-UX Linux Windows]](../images/dist.gif)
![[IBM i]](../images/iseries.gif)
作業主題