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

TnewMBeanProxy(final MBeanServerConnection conn, final ObjectName objectName, final Class interfaceClass)
This method allows you to get at a bean registered with the server.
return (T) MBeanServerInvocationHandler.newProxyInstance(conn, objectName, interfaceClass, false);
ObjectNameobjectNameFor(Logger logger, String mbeanName)
Generates an ObjectName object for a mbean name supplied as String.
try {
    return new ObjectName(mbeanName);
} catch (Throwable ex) {
    logger.warn("Could not create object name.", ex);
return null;
ObjectNameonameForBean(final Object mbean, final String name)
oname For Bean
@SuppressWarnings("UseOfObsoleteCollectionType")
Hashtable<String, String> ht = new Hashtable<String, String>();
Class klass = mbean.getClass();
ht.put("class", klass.getSimpleName());
ht.put("name", name);
return new ObjectName(klass.getPackage().getName(), ht);
booleanoperationEquals(MBeanOperationInfo one, MBeanOperationInfo two)
operation Equals
if (one == two)
    return true;
return (one.getName().equals(two.getName()) && one.getReturnType().equals(two.getReturnType())
        && one.getDescription().equals(two.getDescription()) && one.getImpact() == two.getImpact()
        && infoArrayEquals(one.getSignature(),
                two.getSignature()) );
booleanparamEquals(MBeanParameterInfo o1, MBeanParameterInfo o2)
param Equals
if (o1 == o2)
    return true;
return (o1.getName().equals(o2.getName()) && o1.getType().equals(o2.getType()) && safeEquals(
        o1.getDescription(), o2.getDescription()) );
TqueryAndGetAttribute(MBeanServerConnection connection, String domain, String name, String type, String scope, String attribute)
query And Get Attribute
return queryAndGetAttribute(connection, getObjectName(domain, name, type, scope), attribute);
SetqueryConnectionBy(MBeanServerConnection connection, ObjectName objectName)
query Connection By
return connection.queryMBeans(objectName, null);
ObjectreadAttribute(MBeanServer mbeanServer, String mbeanName, String attributeName)
read Attribute
try {
    ObjectName objectName = new ObjectName(mbeanName);
    return readAttribute(mbeanServer, objectName, attributeName);
} catch (MalformedObjectNameException e) {
    throw new IllegalArgumentException(e);
ObjectInstanceregisterMBean(MBeanServer mbs, Object object, ObjectName name, boolean unreg)
register M Bean
if (unreg) {
    if (mbs.isRegistered(name)) {
        unregisterMBean(mbs, name);
try {
    ObjectInstance ret = mbs.registerMBean(object, name);
    return ret;
...
ObjectNameregisterMBean(MBeanServer server, String agentName, Map attrs, Object mbeanObject)
register M Bean
StringBuilder sb = new StringBuilder(agentName).append(':');
for (String key : attrs.keySet()) {
    sb.append(key).append('=').append(attrs.get(key)).append(',');
if (sb.charAt(sb.length() - 1) == ',') {
    sb.deleteCharAt(sb.length() - 1);
ObjectName oName = new ObjectName(sb.toString());
...