Java 类javax.management.remote.JMXAddressable 实例源码

项目:jmxlocal    文件:WrappedJMXConnector.java   
/**
 * Returns an addressable connector. If the passed connector implements {@link JMXAddressable}, it is simple returned.
 * Otherwise it is wrapped and the {@link JMXAddressable} interface is implemented using the passed service URL.
 * @param jmxConnector The JMXConnector to wrap
 * @param jmxServiceURL The connector's known JMXServiceURL
 * @return a {@link JMXAddressable} implementing JMXConnector
 */
public static JMXConnector addressable(final JMXConnector jmxConnector, final JMXServiceURL jmxServiceURL) {
    if(jmxConnector==null) throw new IllegalArgumentException("The passed JMXConnector was null");
    if(jmxConnector instanceof JMXAddressable) return jmxConnector;
    if(jmxServiceURL==null) throw new IllegalArgumentException("The passed JMXConnector does not implement JMXAddressable, but the passed JMXServiceURL was null");
    return new WrappedJMXConnector(jmxConnector, jmxServiceURL);
}