getAttribute

public Object getAttribute(ObjectName objName, String attrname) 
  throws MBeanException, 
         AttributeNotFoundException, 
         InstanceNotFoundException, 
         ReflectionException;

This API allows the agent layer to retrieve the value of an MBean attribute. (See the JMX documentation on the Attribute class for further details.) From the point of view of the MQe JMX interface, the most important properties of this class are name and value. The getAttribute() method takes two parameters: an ObjectName corresponding to the resource in question (a JMX-instrumented queue, for example) and a String parameter corresponding to the Attribute name. The method returns an Object which must be cast to the expected type of the Attribute value.

So, for example, if a MQe queue MBean has an attribute named Description of type java.lang.String, the value for that attribute would be retrieved at the agent layer as follows (assuming that the ObjectName for the queue in question has been retrieved from a query):
String queueDesc = (String)mbeanServer.getAttribute( queueObjName,
                                                     "Description"); 
This method throws exceptions of type: AttributeNotFoundException, MBeanException, or ReflectionException. MQe Exceptions are returned wrapped in MBeanExceptions. See Error handling.
Note: For the sake of convenience, the try/catch blocks needed to catch exceptions thrown by these MBeanServer methods are omitted in the examples in these sections. See Error handling.

Some adapters such as the Sun HtmlAdaptorServer invoke the getAttribute() and setAttribute() methods recursively when getting or setting several attributes rather than invoking getAttributes() or setAttributes(). This may result in a high overhead. In this case, it is advisable to increase the cacheInterval attribute in the Admin MBean (see the reference Admin MBean). Caching attribute values decreases the amount of work being done by the adaptor.


Terms of use | WebSphere software

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