The WebSphere Application Server configuration values can contain references to WebSphere variables.
This is an important and useful concept that allows substitute values using variables in the configuration. It has some drawback on the other side when you write the jython administrative script. The wsadmin commands does not resolve the variables to values automatically.
For example if you want to obtain the full path to log file you will use following jython commands in wsadmin script:
server = AdminConfig.getid('/Node:AppSrv01Node01/Server:server1');
systemOutLog = AdminConfig.showAttribute(server, 'outputStreamRedirect');
logFileName=AdminConfig.showAttribute(systemOutLog,'fileName');
print logFileName;
The ouptut is:
${SERVER_LOG_ROOT}/SystemOut.log
Not much useful, because you don't know what the value of the SERVER_LOG_ROOT variable.
The following example shows how to resolve the variable values in the Jython code. Each WebSphere Application Server has the mbean AdminOperations in runtime. The AdminOperations has the expandVariable operation that resolves WebSphere variables in the string.
# find the AdminOperations mbean in server runtime
AdminOperations = AdminControl.completeObjectName('WebSphere:*,node=AppSrv01Node01,process=server1,type=AdminOperations');
# call the operation expandVariable on that bean
print AdminControl.invoke(AdminOperations,'expandVariable','${SERVER_LOG_ROOT}/SystemOut.log');
The output is:
C:\IBM\WebSphere\AppServer\profiles\AppSrv01/logs/server1/SystemOut.log
Žádné komentáře:
Okomentovat