jmx 客户端使用用户名密码连接

使用用户名密码连接jmx服务端,代码如下:
HashMap env = null;

		if (!StringUtils.isBlank(username))
		{
			env = new HashMap();
			String[] credentials = new String[] { username, password };
			env.put("jmx.remote.credentials", credentials);
		}

		JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + ip + ":" + port + "/jmxrmi");
		JMXConnector jmxc = JMXConnectorFactory.connect(url, env);
		MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();

Total views.

© 2013 - 2024. All rights reserved.

Powered by Hydejack v6.6.1