Show TOC

 Query MBeansLocate this document in the navigation structure

Often, you do not know the full name of an 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 node:

Tip
import java.util.Set;
import javax.management.ObjectName;
import javax.management.MBeanServerConnection;
import com.sap.jmx.ObjectNameFactory;
MBeanServerConnection mbsc = getConnection ();
// build the ObjectName pattern:
// ":j2eeType=SAP_MyType,SAP_J2EEClusterNode=14418750,SAP_J2EECluster=\"\",*"
ObjectName pattern = ObjectNameFactory.getPatternForServerChildPerNode("SAP_MyType", "14418750", null);
// the query returns a set of matching ObjectNames
Set<ObjectName> names = mbsc.queryNames(pattern, null);

 

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

Tip
...
// build the ObjectName pattern:
// ":j2eeType=SAP_MyType,SAP_J2EECluster=\"\",*"
ObjectName pattern2 = ObjectNameFactory.getPatternForServerChildPerNode("SAP_MyType", null);
// the query returns a set of matching ObjectNames
Set<ObjectName> names2 = mbsc.queryNames(pattern2, null);

 

Note

Both queries apply to the default domain only.