WebSphereJython脚本:查询激活规范的自定义属性

WebSphereJython脚本:查询激活规范的自定义属性,websphere,jython,wsadmin,Websphere,Jython,Wsadmin,如何迭代激活规范的自定义属性?事实上,我想得到“WAS_EndpointInitialState”的值 resourceProperties属性是一个空格分隔的字符串,由方括号包围。以下脚本应适用于您: asList=AdminConfig.list('J2CActivationSpec').splitlines() 对于asList中的as: asName=AdminConfig.showAttribute(作为“名称”) propList=AdminConfig.showAttribute(

如何迭代激活规范的自定义属性?事实上,我想得到“WAS_EndpointInitialState”的值


resourceProperties
属性是一个空格分隔的字符串,由方括号包围。以下脚本应适用于您:

asList=AdminConfig.list('J2CActivationSpec').splitlines()
对于asList中的as:
asName=AdminConfig.showAttribute(作为“名称”)
propList=AdminConfig.showAttribute(作为“resourceProperties”)[1:-1]。拆分()
对于propList中的道具:
打印“name=”+AdminConfig.showAttribute(属性“name”)
打印'value='+AdminConfig.showAttribute(属性'value')
如果属性名的对象ID中有空格,则可能会中断

您可以使用正则表达式处理所有的边缘情况,或者尝试WDR库(),它已经做到了这一点。另外,它使脚本更具可读性和可维护性

使用WDR时,脚本将如下所示:

asList=listConfigObjects('J2CActivationSpec')
对于asList中的as:
asName=as.name
propList=as.resourceProperties
对于propList中的道具:
打印“name=”+prop.name
打印“值=”+属性值
asList = AdminConfig.list('J2CActivationSpec').splitlines()
for as in asList:
    asName = AdminConfig.showAttribute(as, 'name')
    # beyond this point it does not work
    propSet = AdminConfig.showAttribute(as, 'resourceProperties')
    propList = AdminConfig.list('J2EEResourceProperty', propSet).splitlines()
    for prop in propList:
        print 'name = ' + AdminConfig.showAttribute(prop, 'name')
        print 'value = ' + AdminConfig.showAttribute(prop, 'value')