private static MBeanServerConnection Connect(JMXServiceURL url, string username, string password) { IDictionary <string, object> environment = new Dictionary <string, object>(); if (!string.ReferenceEquals(username, null) && !string.ReferenceEquals(password, null)) { environment[JMXConnector.CREDENTIALS] = new string[] { username, password }; } else if (!string.ReferenceEquals(username, null) || !string.ReferenceEquals(password, null)) { throw new System.ArgumentException("User name and password must either both be specified, or both be null."); } try { try { return(JMXConnectorFactory.connect(url, environment).MBeanServerConnection); } catch (SecurityException) { environment[RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE] = new SslRMIClientSocketFactory(); return(JMXConnectorFactory.connect(url, environment).MBeanServerConnection); } } catch (IOException e) { throw new System.InvalidOperationException("Connection failed.", e); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static JmxDump connectTo(String jmxAddress) throws java.io.IOException public static JmxDump ConnectTo(string jmxAddress) { JMXServiceURL url = new JMXServiceURL(jmxAddress); JMXConnector connect = JMXConnectorFactory.connect(url); return(new JmxDump(connect.MBeanServerConnection)); }