类javax.management.remote.JMXConnectorServer源码实例Demo

下面列出了怎么用javax.management.remote.JMXConnectorServer的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: openjdk-jdk9   文件: ProviderTest.java
private static void dotest(JMXServiceURL url, MBeanServer mbs)
    throws Exception {
    JMXConnectorServer server = null;
    JMXConnector client = null;

    server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    server.start();
    JMXServiceURL outputAddr = server.getAddress();
    System.out.println("Server started ["+ outputAddr+ "]");

    client = JMXConnectorFactory.newJMXConnector(outputAddr, null);

    client.connect();
    System.out.println("Client connected");

    MBeanServerConnection connection
        = client.getMBeanServerConnection();

    System.out.println(connection.getDefaultDomain());
}
 
private JMXConnectorServer startServer(int rmiPort) throws Exception {
    System.out.println("DEBUG: Create RMI registry on port " + rmiPort);
    LocateRegistry.createRegistry(rmiPort);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    HashMap<String,Object> env = new HashMap<String,Object>();

    JMXServiceURL url =
            new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:" + rmiPort + "/jmxrmi");
    JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);

    cs.start();
    System.out.println("DEBUG: Started the RMI connector server");
    return cs;
}
 
源代码3 项目: openjdk-8-source   文件: ListenerScaleTest.java
public static void main(String[] args) throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
 
源代码4 项目: dragonwell8_jdk   文件: ListenerScaleTest.java
public static void main(String[] args) throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
 
源代码5 项目: jdk8u_jdk   文件: Agent.java
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
 
源代码6 项目: dragonwell8_jdk   文件: ProviderTest.java
private static void dotest(JMXServiceURL url, MBeanServer mbs)
    throws Exception {
    JMXConnectorServer server = null;
    JMXConnector client = null;

    server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    server.start();
    JMXServiceURL outputAddr = server.getAddress();
    System.out.println("Server started ["+ outputAddr+ "]");

    client = JMXConnectorFactory.newJMXConnector(outputAddr, null);

    client.connect();
    System.out.println("Client connected");

    MBeanServerConnection connection
        = client.getMBeanServerConnection();

    System.out.println(connection.getDefaultDomain());
}
 
源代码7 项目: openjdk-8-source   文件: ProviderTest.java
private static void dotest(JMXServiceURL url, MBeanServer mbs)
    throws Exception {
    JMXConnectorServer server = null;
    JMXConnector client = null;

    server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    server.start();
    JMXServiceURL outputAddr = server.getAddress();
    System.out.println("Server started ["+ outputAddr+ "]");

    client = JMXConnectorFactory.newJMXConnector(outputAddr, null);

    client.connect();
    System.out.println("Client connected");

    MBeanServerConnection connection
        = client.getMBeanServerConnection();

    System.out.println(connection.getDefaultDomain());
}
 
源代码8 项目: TencentKona-8   文件: Agent.java
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
 
源代码9 项目: hottub   文件: Agent.java
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
 
源代码10 项目: brooklyn-server   文件: JmxmpAgent.java
/** optionally starts a normal JMXRMI connector in addition */
public JMXConnectorServer startNormalJmxRmiConnectorIfRequested(Properties properties) {
    try {
        String rmiPortS = properties.getProperty(RMI_REGISTRY_PORT_PROPERTY);
        if (rmiPortS==null || rmiPortS.length()==0)
            return null;

        int rmiPort = Integer.parseInt(rmiPortS);
        LocateRegistry.createRegistry(rmiPort);
        MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
        String svc =
            "service:jmx:rmi:///jndi/rmi://localhost:"+rmiPort+"/jmxrmi";

        JMXServiceURL url = new JMXServiceURL(svc);
        RMIConnectorServer rmiServer = new RMIConnectorServer(url, null, mbeanServer);
        rmiServer.start();
        return rmiServer;
    } catch (Exception e) {
        System.err.println("Unable to start JmxmpAgent: "+e);
        throw new RuntimeException(e);
    }
}
 
源代码11 项目: TencentKona-8   文件: ListenerScaleTest.java
public static void main(String[] args) throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    Sender sender = new Sender();
    mbs.registerMBean(sender, testObjectName);
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
    JMXConnectorServer cs =
        JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    try {
        test(mbs, cs, cc);
    } finally {
        cc.close();
        cs.stop();
    }
}
 
源代码12 项目: jdk8u-jdk   文件: Agent.java
private static synchronized void startLocalManagementAgent() {
    Properties agentProps = VMSupport.getAgentProperties();

    // start local connector if not started
    if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
        JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
        String address = cs.getAddress().toString();
        // Add the local connector address to the agent properties
        agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);

        try {
            // export the address to the instrumentation buffer
            ConnectorAddressLink.export(address);
        } catch (Exception x) {
            // Connector server started but unable to export address
            // to instrumentation buffer - non-fatal error.
            warning(EXPORT_ADDRESS_FAILED, x.getMessage());
        }
    }
}
 
private JMXConnectorServer startServer(int rmiPort) throws Exception {
    System.out.println("DEBUG: Create RMI registry on port " + rmiPort);
    LocateRegistry.createRegistry(rmiPort);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

    HashMap<String,Object> env = new HashMap<String,Object>();

    JMXServiceURL url =
            new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:" + rmiPort + "/jmxrmi");
    JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);

    cs.start();
    System.out.println("DEBUG: Started the RMI connector server");
    return cs;
}
 
源代码14 项目: TencentKona-8   文件: ProviderTest.java
private static void dotest(JMXServiceURL url, MBeanServer mbs)
    throws Exception {
    JMXConnectorServer server = null;
    JMXConnector client = null;

    server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    server.start();
    JMXServiceURL outputAddr = server.getAddress();
    System.out.println("Server started ["+ outputAddr+ "]");

    client = JMXConnectorFactory.newJMXConnector(outputAddr, null);

    client.connect();
    System.out.println("Client connected");

    MBeanServerConnection connection
        = client.getMBeanServerConnection();

    System.out.println(connection.getDefaultDomain());
}
 
源代码15 项目: jdk8u_jdk   文件: ProviderTest.java
private static void dotest(JMXServiceURL url, MBeanServer mbs)
    throws Exception {
    JMXConnectorServer server = null;
    JMXConnector client = null;

    server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    server.start();
    JMXServiceURL outputAddr = server.getAddress();
    System.out.println("Server started ["+ outputAddr+ "]");

    client = JMXConnectorFactory.newJMXConnector(outputAddr, null);

    client.connect();
    System.out.println("Client connected");

    MBeanServerConnection connection
        = client.getMBeanServerConnection();

    System.out.println(connection.getDefaultDomain());
}
 
private void destroyServer(String serverName,
        JMXConnectorServer theConnectorServer) {
    if (theConnectorServer != null) {
        try {
            theConnectorServer.stop();
        } catch (IOException e) {
            log.error(sm.getString(
                    "jmxRemoteLifecycleListener.destroyServerFailed",
                    serverName),e);
        }
    }
}
 
源代码17 项目: openjdk-jdk9   文件: RMIDownloadTest.java
private static void testWithException(boolean send)
throws Exception {
    ClassLoader zoobyCL = new ZoobyClassLoader();
    Class<?> zoobyClass = Class.forName("Zooby", false, zoobyCL);
    Object zooby = zoobyClass.newInstance();

    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///");
    JMXConnectorServer cs =
            JMXConnectorServerFactory.newJMXConnectorServer(url, null, pmbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    MBeanServerConnection mbsc = cc.getMBeanServerConnection();

    Object rzooby;
    if (send) {
        System.out.println("Sending object...");
        mbsc.setAttribute(getSetName, new Attribute("It", zooby));
        rzooby = getSetInstance.getIt();
    } else {
        System.out.println("Receiving object...");
        getSetInstance.setIt(zooby);
        rzooby = mbsc.getAttribute(getSetName, "It");
    }

    if (!rzooby.getClass().getName().equals("Zooby")) {
        throw new Exception("FAILED: remote object is not a Zooby");
    }
    if (rzooby.getClass().getClassLoader() ==
            zooby.getClass().getClassLoader()) {
        throw new Exception("FAILED: same class loader: " +
                zooby.getClass().getClassLoader());
    }

    cc.close();
    cs.stop();
}
 
源代码18 项目: cacheonix-core   文件: Server.java
public static void main(String[] args) throws Exception
{
   // The MBeanServer
   MBeanServer server = MBeanServerFactory.createMBeanServer();

   // Pass null as the host name to tell JMXServiceURL to default to InetAddress.getLocalHost().getHostName()
   JMXServiceURL url = new JMXServiceURL("hessian", null, 8080, "/hessian");

   JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
   connectorServer.start();

   System.out.println("Server up and running " + connectorServer + " on " + url);
}
 
源代码19 项目: jdk8u-jdk   文件: ServerProvider.java
public JMXConnectorServer newJMXConnectorServer(JMXServiceURL serviceURL,
                                                Map<String,?> environment,
                                                MBeanServer mbeanServer)
        throws IOException {
    if (!serviceURL.getProtocol().equals("rmi")) {
        throw new MalformedURLException("Protocol not rmi: " +
                                        serviceURL.getProtocol());
    }
    return new RMIConnectorServer(serviceURL, environment, mbeanServer);
}
 
源代码20 项目: dragonwell8_jdk   文件: ConnectorBootstrap.java
/**
 * Initializes and starts the JMX Connector Server.
 * If the com.sun.management.jmxremote.port property is not defined,
 * simply return. Otherwise, attempts to load the config file, and
 * then calls {@link #startRemoteConnectorServer
 *                            (java.lang.String, java.util.Properties)}.
 *
 * This method is used by some jtreg tests.
 **/
 public static synchronized JMXConnectorServer initialize() {

    // Load a new management properties
    final Properties props = Agent.loadManagementProperties();
    if (props == null) {
         return null;
    }

    final String portStr = props.getProperty(PropertyNames.PORT);
    return startRemoteConnectorServer(portStr, props);
}
 
源代码21 项目: hottub   文件: ServerProvider.java
public JMXConnectorServer newJMXConnectorServer(JMXServiceURL serviceURL,
                                                Map<String,?> environment,
                                                MBeanServer mbeanServer)
        throws IOException {
    if (!serviceURL.getProtocol().equals("rmi")) {
        throw new MalformedURLException("Protocol not rmi: " +
                                        serviceURL.getProtocol());
    }
    return new RMIConnectorServer(serviceURL, environment, mbeanServer);
}
 
源代码22 项目: jdk8u60   文件: MapNullValuesTest.java
private int jmxConnectorServerFactoryTests() {
    int errorCount = 0;
    echo("");
    echo(dashedMessage("Run JMXConnectorServerFactory Tests"));
    for (int i = 0; i < maps.length - 1; i++) {
        echo("\n>>> JMXConnectorServerFactory Test [" + i + "]");
        try {
            echo("\tMap = " + maps[i]);
            echo("\tCreate the MBean server");
            MBeanServer mbs = MBeanServerFactory.createMBeanServer();
            echo("\tCreate the RMI connector server");
            JMXServiceURL url =
                new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:" +
                                  port + "/JMXConnectorServerFactory" + i);
            JMXConnectorServer jmxcs =
                JMXConnectorServerFactory.newJMXConnectorServer(url,
                                                                maps[i],
                                                                mbs);
            echo("\tStart the RMI connector server");
            jmxcs.start();
            echo("\tCall RMIConnectorServer.toJMXConnector(Map)");
            jmxcs.toJMXConnector(maps[i]);
            echo("\tStop the RMI connector server");
            jmxcs.stop();
            echo("\tTest [" + i + "] PASSED!");
        } catch (Exception e) {
            errorCount++;
            echo("\tTest [" + i + "] FAILED!");
            e.printStackTrace(System.out);
        }
    }
    if (errorCount == 0) {
        echo("");
        echo(dashedMessage("JMXConnectorServerFactory Tests PASSED!"));
    } else {
        echo("");
        echo(dashedMessage("JMXConnectorServerFactory Tests FAILED!"));
    }
    return errorCount;
}
 
源代码23 项目: cacheonix-core   文件: Server.java
public static void main(String[] args) throws Exception
{
   // The MBeanServer
   MBeanServer server = MBeanServerFactory.createMBeanServer();

   // Pass null as the host name to tell JMXServiceURL to default to InetAddress.getLocalHost().getHostName()
   JMXServiceURL url = new JMXServiceURL("soap", null, 8080, "/jmxconnector");

   // Create and start the connector server
   // Jetty will listen on port 8080
   JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
   connectorServer.start();

   System.out.println("Server up and running " + connectorServer);
}
 
源代码24 项目: hottub   文件: Server.java
public static String start() throws Exception {
    int serverPort = 12345;
    ObjectName name = new ObjectName("test", "foo", "bar");
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    SteMBean bean = new Ste();
    jmxServer.registerMBean(bean, name);
    boolean exported = false;
    Random rnd = new Random(System.currentTimeMillis());
    do {
        try {
            LocateRegistry.createRegistry(serverPort);
            exported = true;
        } catch (ExportException ee) {
            if (ee.getCause() instanceof BindException) {
                serverPort = rnd.nextInt(10000) + 4096;
            } else {
                throw ee;
            }
        }

    } while (!exported);
    JMXServiceURL serverUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + serverPort + "/test");
    JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(serverUrl, null, jmxServer);
    jmxConnector.start();

    return serverUrl.toString();
}
 
源代码25 项目: openjdk-jdk9   文件: ServerProvider.java
public JMXConnectorServer newJMXConnectorServer(JMXServiceURL serviceURL,
                                                Map<String,?> environment,
                                                MBeanServer mbeanServer)
        throws IOException {
    if (!serviceURL.getProtocol().equals("rmi")) {
        throw new MalformedURLException("Protocol not rmi: " +
                                        serviceURL.getProtocol());
    }
    return new RMIConnectorServer(serviceURL, environment, mbeanServer);
}
 
源代码26 项目: openjdk-8   文件: Server.java
public static String start() throws Exception {
    int serverPort = 12345;
    ObjectName name = new ObjectName("test", "foo", "bar");
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    SteMBean bean = new Ste();
    jmxServer.registerMBean(bean, name);
    boolean exported = false;
    Random rnd = new Random(System.currentTimeMillis());
    do {
        try {
            LocateRegistry.createRegistry(serverPort);
            exported = true;
        } catch (ExportException ee) {
            if (ee.getCause() instanceof BindException) {
                serverPort = rnd.nextInt(10000) + 4096;
            } else {
                throw ee;
            }
        }

    } while (!exported);
    JMXServiceURL serverUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + serverPort + "/test");
    JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(serverUrl, null, jmxServer);
    jmxConnector.start();

    return serverUrl.toString();
}
 
源代码27 项目: cacheonix-core   文件: Server.java
public static void main(String[] args) throws Exception
{
   // The MBeanServer
   MBeanServer server = MBeanServerFactory.createMBeanServer();

   // Register and start the tnameserv MBean, needed by JSR 160 RMIConnectorServer over IIOP
   // You can also start the new JDK 1.4 'orbd' daemon, but you should do so externally
   // as there are no MBeans that wrap it.
   ObjectName namingName = ObjectName.getInstance("naming:type=tnameserv");
   server.createMBean("mx4j.tools.naming.CosNamingService", namingName, null);
   // Standard port for the COS naming service is 900, but that's a restricted port on Unix/Linux systems
   int namingPort = 1199;
   server.setAttribute(namingName, new Attribute("Port", new Integer(namingPort)));
   server.invoke(namingName, "start", null, null);

   String jndiPath = "/jmxconnector";
   // Note how the JMXServiceURL specifies 'iiop' as protocol for both the
   // JMXConnectorServer (the first), to indicate the protocol of the JMXConnectorServer,
   // and for the naming server (the second), to indicate that this is not the rmiregistry
   // but the COS naming service.
   JMXServiceURL url = new JMXServiceURL("service:jmx:iiop://localhost/jndi/iiop://localhost:" + namingPort + jndiPath);

   // Create and start the RMIConnectorServer over IIOP
   JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
   connectorServer.start();

   System.out.println("Server up and running");
}
 
源代码28 项目: dragonwell8_jdk   文件: IIOPURLTest.java
public static void main(String[] args) throws Exception {
    JMXServiceURL inputAddr =
        new JMXServiceURL("service:jmx:iiop://");
    JMXConnectorServer s;
    try {
        s = JMXConnectorServerFactory.newJMXConnectorServer(inputAddr, null, null);
    } catch (java.net.MalformedURLException x) {
        try {
            Class.forName("javax.management.remote.rmi._RMIConnectionImpl_Tie");
            throw new RuntimeException("MalformedURLException thrown but iiop appears to be supported");
        } catch (ClassNotFoundException expected) { }
        System.out.println("IIOP protocol not supported, test skipped");
        return;
    }
    MBeanServer mbs = MBeanServerFactory.createMBeanServer();
    mbs.registerMBean(s, new ObjectName("a:b=c"));
    s.start();
    JMXServiceURL outputAddr = s.getAddress();
    if (!outputAddr.getURLPath().startsWith("/ior/IOR:")) {
        throw new RuntimeException("URL path should start with \"/ior/IOR:\": " +
                                   outputAddr);
    }
    System.out.println("IIOP URL path looks OK: " + outputAddr);
    JMXConnector c = JMXConnectorFactory.connect(outputAddr);
    System.out.println("Successfully got default domain: " +
                       c.getMBeanServerConnection().getDefaultDomain());
    c.close();
    s.stop();
}
 
源代码29 项目: openjdk-8-source   文件: Server.java
public static String start() throws Exception {
    int serverPort = 12345;
    ObjectName name = new ObjectName("test", "foo", "bar");
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    SteMBean bean = new Ste();
    jmxServer.registerMBean(bean, name);
    boolean exported = false;
    Random rnd = new Random(System.currentTimeMillis());
    do {
        try {
            LocateRegistry.createRegistry(serverPort);
            exported = true;
        } catch (ExportException ee) {
            if (ee.getCause() instanceof BindException) {
                serverPort = rnd.nextInt(10000) + 4096;
            } else {
                throw ee;
            }
        }

    } while (!exported);
    JMXServiceURL serverUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + serverPort + "/test");
    JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(serverUrl, null, jmxServer);
    jmxConnector.start();

    return serverUrl.toString();
}
 
public JMXConnectorServer newJMXConnectorServer(JMXServiceURL url,
                                                Map<String,?> map,
                                                MBeanServer mbeanServer)
    throws IOException {
    final String protocol = url.getProtocol();
    called = true;
    System.out.println("JMXConnectorServerProviderImpl called");
    if(protocol.equals("rmi"))
        return new RMIConnectorServer(url, map, mbeanServer);
    if(protocol.equals("throw-provider-exception"))
        throw new JMXProviderException("I have been asked to throw");

    throw new IllegalArgumentException("UNKNOWN PROTOCOL");
}
 
 类所在包
 同包方法