wsadmin:如何检查现有资源引用?

时间:2011-11-22 13:21:00

标签: websphere mbeans wsadmin

使用$AdminApp view <applicationName> -MapResRefToEJB,可以列出为已部署的EJB模块定义的资源引用。但是,该命令的结果是纯文本(另外可能是本地化的)。要提取该信息,必须解析此文本,这不是很方便。有没有办法使用$ AdminConfig以结构化形式获取相同的信息(即应用程序的资源引用)?

1 个答案:

答案 0 :(得分:4)

AppManagement MBean以结构化格式(AppDeploymentTasks的向量)提供此数据。要使用wsadmin脚本(jython)获取此数据:

import javax.management as mgmt
appName = sys.argv[0]
appMgmt = mgmt.ObjectName(AdminControl.completeObjectName("WebSphere:*,type=AppManagement"))
appInfo = AdminControl.invoke_jmx(appMgmt, "getApplicationInfo", [appName, java.util.Hashtable(), None], ["java.lang.String", "java.util.Hashtable", "java.lang.String"])
for task in appInfo :
    if (task.getName() == "MapResRefToEJB") :
        resRefs = task.getTaskData()
        # skip the first row since it contains the headers
        for i in range(1, len(resRefs)) :
            resRef = resRefs[i]
            print
            print "URI:", resRef[4]
            print "EJB:", resRef[3]
            print "Name:", resRef[5]
            print "Type:", resRef[6]
            print "JNDI:", resRef[8]