首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

JMX协议联接方式

2013-09-14 
JMX协议连接方式JMX协议的实现由IIOP和JMXMP,其连接方式有所不同:IIOP如下:?HashtableString, Object en

JMX协议连接方式

JMX协议的实现由IIOP和JMXMP,其连接方式有所不同:

IIOP如下:

?

Hashtable<String, Object> env = new Hashtable<String, Object>();String prividerUrl = "iiop://" + host + ":" + port;String[] credentials = new String[] { userName, userPwd };env.clear();env.put(Context.PROVIDER_URL, prividerUrl);env.put(JMXConnector.CREDENTIALS, credentials);env.put(Context.AUTHORITATIVE, userName);env.put(Context.SECURITY_CREDENTIALS, userPwd);try {   JMXServiceURL url = new JMXServiceURL("iiop", host, port, "/jndi/corbaname::1.2@" + host + ":" + port + "#jmx/rmi/RMIConnectorServer");   connector = JMXConnectorFactory.connect(url, env);} catch (MalformedURLException e) {   throw new OperationNoSuccessException("connection to connector server fail,either no legal protocol could be found in a specification string or the string could not be parsed", e);} catch (IOException e) {   throw new OperationNoSuccessException("connection to connector server fail", e);}

?

?

JMXMP如下:

?

try {   url = new JMXServiceURL("service:jmx:jmxmp://" + host + ":" + port);} catch (MalformedURLException e) {   throw new RuntimeException(e);}Hashtable<String, Object> env = new Hashtable<String, Object>();env.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "com.sun.jmx.remote.protocol");env.put("jmx.remote.profiles", "SASL/PLAIN");env.put("jmx.remote.sasl.callback.handler", new SaslUserPasswordCallbackHandler(userName, userPwd));env.put(GenericConnector.MESSAGE_CONNECTION, new MuxSocketClientMessageConnection(url.getHost(), url.getPort()));// install SASL/PLAIN mechanism providerSaslClientSecurityProvider.install();if (url != null) {    return JMXConnectorFactory.connect(url, env);}

?

?
?

?

?

热点排行