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

ObjectNamechooseMBean(Set mbeans)
choose M Bean
if (mbeans.size() == 1) {
    return mbeans.iterator().next();
for (ObjectName mbean : mbeans) {
    if (!isHawtioDummy(mbean.toString())) {
        return mbean;
return null;
ObjectNamecomposeMBeanName(String objTypeName, String objInstanceName)
compose M Bean Name
String name = "com.cloud:type=" + objTypeName;
if (objInstanceName != null && !objInstanceName.isEmpty())
    name += ", name=" + objInstanceName;
return new ObjectName(name);
OpenMBeanAttributeInfoconvertToOpenMBeanAttribute(final MBeanAttributeInfo in, final String prefix)
convert To Open M Bean Attribute
return createOpenMBeanAttributeInfo(getOpenType(in.getType()), in, prefix);
OpenMBeanOperationInfoconvertToOpenMBeanOperation(MBeanOperationInfo in)
convert To Open M Bean Operation
return convertToOpenMBeanOperation(in, null, null);
MBeanServercreateMBeanServer()
Create and configure (if necessary) and return the MBeanServer with which we will be registering our ModelMBean implementations.
if (mbeanServer == null) {
    mbeanServer = MBeanServerFactory.createMBeanServer(DEFAULT_DOMAIN);
return mbeanServer;
OpenMBeanAttributeInfocreateOpenMBeanAttributeInfo(final OpenType type, final MBeanAttributeInfo in, final String prefix)
create Open M Bean Attribute Info
return new OpenMBeanAttributeInfoSupport(((prefix != null) ? prefix + in.getName() : in.getName()),
        in.getDescription(), type, in.isReadable(), in.isWritable(), in.isIs());
ObjectcreateProxy(final ObjectName objectName, final Class mbeanInterface, final MBeanServer mbeanServer)
create Proxy
return MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, mbeanInterface, false);
ObjectInstancecreateTimerMBean(ObjectName name, MBeanServer server)
create Timer M Bean
return server.createMBean(TIMER_MBEAN_CLASSNAME, name, null, null);
voiddumpAttributes(MBeanAttributeInfo[] attributes)
dump Attributes
System.out.println("");
System.out.println("Attributes:");
for (int i = 0; i < attributes.length; i++) {
    StringBuffer dump = new StringBuffer();
    MBeanAttributeInfo attribute = attributes[i];
    dump.append("name=").append(attribute.getName());
    dump.append(",type=").append(attribute.getType());
    dump.append(",readable=").append(attribute.isReadable());
...
voiddumpConstructors(MBeanConstructorInfo[] constructors)
dump Constructors
System.out.println("");
System.out.println("Constructors:");
for (int i = 0; i < constructors.length; i++) {
    StringBuffer dump = new StringBuffer();
    MBeanConstructorInfo constructor = constructors[i];
    dump.append("name=").append(constructor.getName());
    dump.append(",signature=").append(makeSignatureString(constructor.getSignature()));
    System.out.println(dump);
...