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

MapgetMBeanConnections(final Map connectors)
get M Bean Connections
Map<String, MBeanServerConnection> mBeanConnections = Maps.newConcurrentMap();
for (String service : connectors.keySet()) {
    mBeanConnections.put(service, connectors.get(service).getMBeanServerConnection());
return mBeanConnections;
ObjectNamegetMBeanName(final String serviceName, final String nameName)
get M Bean Name
ObjectName name = null;
try {
    name = new ObjectName("Lily:" + "service=" + serviceName + ",name=" + nameName);
} catch (MalformedObjectNameException e) {
    throw new RuntimeException(e);
return name;
SetgetMbeans(final MBeanServerConnection mBeanServerConnection)
Return a list of ZMQ MBean instances.
final ObjectName objectQueryName = new ObjectName("org.zeromq:type=ZMQ,*");
final Set<ObjectInstance> objectInstances = mBeanServerConnection.queryMBeans(objectQueryName, null);
return objectInstances;
MBeanServergetMBeanServer()
get M Bean Server
List servers = MBeanServerFactory.findMBeanServer(null);
return servers == null || servers.size() == 0 ? null : (MBeanServer) servers.get(0);
MBeanServergetMbeanServer()
get Mbean Server
synchronized (synchThis) {
    if (mbeanServer != null) {
        return mbeanServer;
    mbeanServer = MBeanServerFactory.findMBeanServer(null).iterator().next();
return mbeanServer;
MBeanServergetMBeanServer()
return the local MbeanServer by using the system property jboss.remoting.jmxid which is set by the NetworkRegistry MBean when registered in the mbean server
ArrayList list = MBeanServerFactory.findMBeanServer(System.getProperty("jboss.remoting.jmxid"));
if (list.isEmpty()) {
    return null;
return (MBeanServer) list.iterator().next();
MBeanServergetMBeanServer()
get M Bean Server
if (mbserver == null) {
    final ArrayList<MBeanServer> mbservers = MBeanServerFactory.findMBeanServer(null);
    if (mbservers.size() > 0) {
        mbserver = mbservers.get(0);
    if (mbserver == null) {
        mbserver = MBeanServerFactory.createMBeanServer();
return mbserver;
MBeanServergetMBeanServer()
get M Bean Server
if (mbeanServer == null) {
    if (MBeanServerFactory.findMBeanServer(null).size() > 0) {
        mbeanServer = MBeanServerFactory.findMBeanServer(null).get(0);
    } else {
        mbeanServer = MBeanServerFactory.createMBeanServer();
return mbeanServer;
...
MBeanServergetMBeanServer()
get M Bean Server
ArrayList<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null);
if (servers != null && !servers.isEmpty()) {
    for (int i = 0; i < servers.size(); i++) {
        MBeanServer server = servers.get(i);
        if (DOMAIN_NAME.equalsIgnoreCase(server.getDefaultDomain())) {
            return server;
    return (MBeanServer) servers.get(0);
} else {
    return MBeanServerFactory.createMBeanServer(DOMAIN_NAME);
MBeanServerConnectiongetMBeanServerConnection(final JMXConnector connector)
get M Bean Server Connection
try {
    return connector.getMBeanServerConnection();
} catch (Exception ex) {
    throw new RuntimeException("Failed to get MBeanServerConnection from [" + connector + "]", ex);