JmxRmi.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:QD 作者:
static JmxConnector init(Properties props) throws IOException {
    Integer port = Integer.decode(props.getProperty(JMXEndpoint.JMX_RMI_PORT_PROPERTY));

    if (!JmxConnectors.isPortAvailable(port))
        return null;

    String name = "com.devexperts.qd.monitoring:type=RmiServer,port=" + port;
    RMIJRMPServerImpl srvImpl = new RMIJRMPServerImpl(port, null, null, null);
    RMIConnectorServer rmiServer = new RMIConnectorServer(
        new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:" + port +  "/jmxrmi"),
        null, srvImpl, ManagementFactory.getPlatformMBeanServer());
    ConnectorImpl connector = new ConnectorImpl(name, rmiServer);
    if (!JmxConnectors.addConnector(port, connector))
        return null; // port is already taken

    LocateRegistry.createRegistry(port);
    connector.setRegistration(Management.registerMBean(rmiServer, null, name));
    rmiServer.start();
    QDLog.log.info("RMI management port is " + port);
    return connector;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号