Java MBean getMBeanServer()

Here you can find the source of getMBeanServer()

Description

get M Bean Server

License

Apache License

Declaration

public static MBeanServer getMBeanServer() 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;

import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;

public class Main {
    public static final String DOMAIN_NAME = "TankWar";

    public static MBeanServer getMBeanServer() {

        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;
                }//from w ww  .  ja  v a2 s.  c om
            }

            return (MBeanServer) servers.get(0);
        } else {
            return MBeanServerFactory.createMBeanServer(DOMAIN_NAME);
        }
    }
}

Related

  1. getMBeanServer()
  2. getMbeanServer()
  3. getMBeanServer()
  4. getMBeanServer()
  5. getMBeanServer()
  6. getMBeanServerConnection(final JMXConnector connector)
  7. getMbeanServerConnection(final JMXConnector jmxConnector)
  8. getMBeanServerConnectionForJMXClient()
  9. getMBeanServerDelegateName()