Java Utililty Methods MBean

List of utility methods to do MBean

Description

The list of methods to do MBean are organized into topic(s).

Method

MBeanServerConnectiongetMbeanServerConnection(final JMXConnector jmxConnector)
get Mbean Server Connection
MBeanServerConnection mBeanServerConnection = null;
if (jmxConnector != null) {
    try {
        mBeanServerConnection = jmxConnector.getMBeanServerConnection();
    } catch (final IOException e) {
        e.printStackTrace();
return mBeanServerConnection;
MBeanServerConnectiongetMBeanServerConnectionForJMXClient()
get M Bean Server Connection For JMX Client
JMXServiceURL jmxURL = new JMXServiceURL(getJMXRMIServiceURL());
JMXConnector _jmxConnector = JMXConnectorFactory.connect(jmxURL);
return _jmxConnector.getMBeanServerConnection();
ObjectNamegetMBeanServerDelegateName()
Lookup the server delegate name, which works for sure for Java 1.6 but maye not for Java 1.5.
try {
    return MBeanServerDelegate.DELEGATE_NAME;
} catch (NoSuchFieldError error) {
    return newObjectName("JMImplementation:type=MBeanServerDelegate");
StringgetMBeanServerId(final MBeanServer aMBeanServer)
Get the MBeanServerId of Agent ID for the provided MBeanServer.
String serverId = null;
final String SERVER_DELEGATE = "JMImplementation:type=MBeanServerDelegate";
final String MBEAN_SERVER_ID_KEY = "MBeanServerId";
try {
    ObjectName delegateObjName = new ObjectName(SERVER_DELEGATE);
    serverId = (String) aMBeanServer.getAttribute(delegateObjName, MBEAN_SERVER_ID_KEY);
} catch (MalformedObjectNameException malformedObjectNameException) {
} catch (AttributeNotFoundException noMatchingAttrException) {
...
ObjectNamegetMBeanServerObjectName()
get the ObjectName of the MBeanServer
if (mbeanserver == null) {
    mbeanserver = new ObjectName("JMImplementation:type=MBeanServerDelegate");
return mbeanserver;
MBeanOperationInfogetOperation(MBeanInfo info, String opName)
Returns the first operation with the specified name.
MBeanOperationInfo[] ops = info.getOperations();
for (int i = 0; i < ops.length; i++) {
    if (ops[i].getName().equals(opName))
        return ops[i];
return null;
TgetProxy(MBeanServerConnection connection, ObjectName objectName, final Class objectClass)
get Proxy
return JMX.newMBeanProxy(connection, objectName, objectClass, true);
StringgetServerId(MBeanServer server)
get the MBeanServerId attribute from the server
if (server == null) {
    throw new NullPointerException("MBeanServer is null");
if (mbeanserver == null) {
    mbeanserver = new ObjectName("JMImplementation:type=MBeanServerDelegate");
return (String) server.getAttribute(mbeanserver, "MBeanServerId");
booleaninfoArrayEquals(MBeanParameterInfo[] a, MBeanParameterInfo[] a2)
info Array Equals
if (a == a2)
    return true;
if (a == null || a2 == null)
    return false;
int length = a.length;
if (a2.length != length)
    return false;
for (int i = 0; i < length; i++) {
...
booleaninfoEquals(MBeanInfo one, MBeanInfo two)
info Equals
if (one == two)
    return true;
if (!safeStringEquals(one.getClassName(), two.getClassName())
        || !safeStringEquals(one.getDescription(), two.getDescription()))
    return false;
return true;