Show TOC Start of Content Area

Background documentation Query MBeans  Locate the document in its SAP Library structure

Often, you do not know the full name of a MBean in advance, but you want to query all MBeans whose ObjectNames match a given pattern. The following example returns all MBeans of a certain type on the given element:

Example

import java.util.Set;

import javax.management.ObjectName;

import javax.management.MBeanServerConnection;

import com.sap.jmx.ObjectNameFactory;

...

MBeanServerConnection mbsc;

...

// build the ObjectName pattern:

// ":*,j2eeType=SAP_MyType,SAP_J2EEClusterNode=4001,SAP_J2EECluster=\"\""

ObjectName pattern = ObjectNameFactory.getPatternForServerChildPerNode("SAP_MyType", "4001", null);

// the query returns a set of matching ObjectNames

Set names = mbsc.queryName(pattern, null);

 

Another example shows a query that returns all MBeans of a certain type on all elements, assuming that the given type is a local MBean. This will result in a broadcast to all cluster elements, performed by the MBean Server internally:

Example

...

// build the ObjectName pattern:

// ":*,j2eeType=SAP_MyType,SAP_J2EECluster=\"\""

ObjectName pattern = ObjectNameFactory.getPatternForServerChildPerNode("SAP_MyType", null);

// the query returns a set of matching ObjectNames

Set names = mbsc.queryName(pattern, null);

 

Note

Both queries apply to the default domain only.

 

 

End of Content Area