getMBeanInfo

public MBeanInfo getMBeanInfo(ObjectName objName)
  throws InstanceNotFoundException, 
         IntrospectionException, 
         ReflectionException;

In order to use some of the other MBeanServer methods described in this section, such as the invoke() method, you need information about the relevant input parameters. For example, you may need to know what operations can be invoked upon a given resource, what input parameters are required for a particular operation, what the type of each of these parameters is and what the return value type is.

There are two ways in which you can obtain this information. Firstly, you can use the list of attributes and operations for each MQe JMX-instrumented resource in JMX Attributes and operations. You can look up the information that you need and hard-code it into an application as required.

Alternatively, you can use the getMBeanInfo() MBeanServer method that the agent layer provides to retrieve the input parameter information. This method takes as its sole parameter the ObjectName instance that corresponds to the equivalent MQe resource. The method returns a complex structure that contains information on the following properties of an MBean: class name, description, attributes, constructors, operations, notifications.

The information that the getMBeanInfo() method returns on attributes, constructors, operations and notifications consists of further structures of types MBeanAttributeInfo, MBeanConstructorInfo, MBeanOperationInfo and MBeanNotificationInfo. The method can also retrieve an MBeanParameterInfo instance that corresponds to each MBeanOperationInfo instance, and so on.

Below is one example of how to use the getMBeanInfo() method. Given the complexity of the MBeanInfo object, you will also find it helpful to refer to the JMX information sources listed in the Related Material section.

Suppose you know that an instrumented MQe application queue MBean has an addAlias method but you want to check the return type of this method. To do this, you would use the getMBeanInfo() method as follows:

/* call the getMBeanInfo() method on              */
/*  the MBeanServer instance for the queue MBean  */
MBeanInfo beanInfo = mbeanServer.getMBeanInfo(queueObjName);

/* retrieve information on operations for that MBean */
MBeanOperationInfo[] beanOps = beanInfo.getOperations();
  
/* loop through the operations until we find the one we want */
for(int i = 0; i < beanOps.length; i++) {
    if(beanOps[i].getName().equals("addAlias")) {
      /* get the return type for that operation */
      String retval = beanOps[i].getReturnType();
      System.out.println(retval);
      break;
    }

A very useful aspect of these information structures is the description parameter. Instances of MBeanAttributeInfo, MBeanParameterInfo, MBeanConstructorInfo and MBeanOperationInfo all have a getDescription() method, which you can use to return a text description of the item in question.


Terms of use | WebSphere software

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