JMXExecutor.java 文件源码

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

项目:openjdk-jdk10 作者:
/**
 * Instantiates a new JMXExecutor targeting the VM indicated by the given host/port combination or a full JMX
 * Service URL
 *
 * @param target a host/port combination on the format "host:port" or a full JMX Service URL of the target VM
 */
public JMXExecutor(String target) {
    String urlStr;

    if (target.matches("^\\w[\\w\\-]*(\\.[\\w\\-]+)*:\\d+$")) {
        /* Matches "hostname:port" */
        urlStr = String.format("service:jmx:rmi:///jndi/rmi://%s/jmxrmi", target);
    } else if (target.startsWith("service:")) {
        urlStr = target;
    } else {
        throw new IllegalArgumentException("Could not recognize target string: " + target);
    }

    try {
        JMXServiceURL url = new JMXServiceURL(urlStr);
        JMXConnector c = JMXConnectorFactory.connect(url, new HashMap<>());
        mbs = c.getMBeanServerConnection();
    } catch (IOException e) {
        throw new CommandExecutorException("Could not initiate connection to target: " + target, e);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号