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

594 Views Asked by At

How do you iterate a array of 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()

If I do something like this I am getting..

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

I have verified that when you execute driverParams[0] that I am getting something like this

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})

Looking at the attribute, I would like to validate the SupportedDeliveryTypes value

name=SupportedDeliveryTypes
value=EMAIL
description=Supported Delivery Types
1

There are 1 best solutions below

0
On BEST ANSWER

CompositeDataSupport is not an array.

To view its content you can try using toString() (in your sample driverParams[0].toString()) or access values with values() or get(String key) / getAll(String[] keys).

For example, try with:

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()