getAttributes

public AttributeList getAttributes( ObjectName name, 
                                    String[] attributes)
  throws InstanceNotFoundException, 
          ReflectionException;

The attributes parameter consists of an array of the names of attributes to be retrieved. The relevant names are listed in reference JMX Attributes and operations. The return value is of type javax.management.AttributeList extends java.util.ArrayList and provides methods for adding Attribute objects to an AttributeList. Attributes are retrieved from an AttributeList using an instance of Iterator and the Attribute class methods getName() and getValue().

String[] attributeNames = {"Description","Expiry"};
AttributeList myAttrs = 
  mbeanServer.getAttributes(queueObjName,attributeNames);
Iterator myIter = myAttrs.iterator();
while(myIter.hasNext()) {
  Attribute attribute = (Attribute)myIter.next();
  System.out.println("Attribute name: " + attribute.getName());
  System.out.println("Attribute value: " + attribute.getValue());
}

The corresponding method for getAttributes() at the instrumentation level cannot throw user exceptions. This limits the usefulness of getAttributes() at the agent layer as, for example, MQe exceptions cannot be retrieved. Instead of using getAttributes(), it may be more useful to loop through the String array of attribute names (attributeNames), calling getAttribute() for each, though this increases the overhead. The same applies to setAttributes().


Terms of use | WebSphere software

(c) Copyright IBM Corporation 2004, 2005. All rights reserved.