如何在wlst中迭代javax.management.openmbean.CompositeDataSupport

How to iterate javax.management.openmbean.CompositeDataSupport in wlst

如何迭代 javax.management.openmbean.CompositeDataSupport 的数组?

myBean = ObjectName('com.oracle.sdp.messaging:Location=my_soa_server,name=EmailDriverConfig,type=SDPMessagingDriverConfig,Application=usermessagingdriver-email')

driverParams = mbs.getAttribute(myBean,'DriverParameterProperties')
for param in driverParams:
  ####How to do iterate and do an if on a name#####
    print param.getName()

如果我这样做,我会得到..

Traceback (innermost last):
  File "<console>", line 1, in ?
AttributeError: getName

我已经验证了当你执行 driverParams[0] 时我得到了这样的东西

javax.management.openmbean.CompositeDataSupport(compositeType=javax.management.openmbean.CompositeType(name=Property,items=((itemName=allowedValues,itemType=javax.management.openmbean.ArrayType(name=[Ljavax.management.openmbean.CompositeData;,dimension=1,elementType=javax.management.openmbean.CompositeType(name=AllowedValue,items=((itemName=label,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),(itemName=value,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)))),primitiveArray=false)),(itemName=description,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),(itemName=encodedCredential,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),(itemName=mandatory,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),(itemName=name,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),(itemName=type,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)),(itemName=value,itemType=javax.management.openmbean.SimpleType(name=java.lang.String)))),contents={allowedValues=[], description=Supported Delivery Types, encodedCredential=false, mandatory=yes, name=SupportedDeliveryTypes, type=java.lang.String, value=EMAIL})

查看属性,我想验证 SupportedDeliveryTypes 值

name=SupportedDeliveryTypes
value=EMAIL
description=Supported Delivery Types

CompositeDataSupport 不是数组。

要查看其内容,您可以尝试使用 toString()(在您的示例 driverParams[0].toString() 中)或使用 values()get(String key) / getAll(String[] keys) 访问值。

例如,尝试使用:

myBean = ObjectName('com.oracle.sdp.messaging:Location=my_soa_server,name=EmailDriverConfig,type=SDPMessagingDriverConfig,Application=usermessagingdriver-email')

driverParams = mbs.getAttribute(myBean,'DriverParameterProperties')
for param in driverParams:
    print param.toString()