Here you can find the source of getMBeanServerConnection(final JMXConnector connector)
public static MBeanServerConnection getMBeanServerConnection(final JMXConnector connector)
//package com.java2s; //License from project: Apache License import java.util.Map; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; public class Main { public static MBeanServerConnection getMBeanServerConnection(final JMXConnector connector) { try {//from w ww.j a va 2s.c o m return connector.getMBeanServerConnection(); } catch (Exception ex) { throw new RuntimeException("Failed to get MBeanServerConnection from [" + connector + "]", ex); } } public static MBeanServerConnection getMBeanServerConnection(final CharSequence jmxUrl) { try { return getJMXConnection(jmxUrl).getMBeanServerConnection(); } catch (Exception ex) { throw new RuntimeException("Failed to get MBeanServerConnection from [" + jmxUrl + "]", ex); } } /** * Acquires a connected JMX connection * @param jmxUrl The JMXServiceURL of the service to connec to * @return a JMXConnector */ public static JMXConnector getJMXConnection(CharSequence jmxUrl) { return getJMXConnection(jmxUrl, true, null); } /** * Acquires a JMX connection * @param jmxUrl The JMXServiceURL of the service to connec to * @param connect If true, the returned connector will be connected * @param environment a set of attributes to determine how the connection is made. Can be null. * @return a JMXConnector */ public static JMXConnector getJMXConnection(CharSequence jmxUrl, boolean connect, Map<String, ?> environment) { if (jmxUrl == null) throw new IllegalArgumentException("The passed JMXServiceURL was null", new Throwable()); try { JMXConnector connector = JMXConnectorFactory .newJMXConnector(new JMXServiceURL(jmxUrl.toString().trim()), environment); if (connect) { connector.connect(); } return connector; } catch (Exception e) { e.printStackTrace(System.err); throw new RuntimeException("Failed to acquire JMXConnection to [" + jmxUrl + "]", e); } } }