本文整理汇总了Java中javax.management.remote.jmxmp.JMXMPConnectorServer类的典型用法代码示例。如果您正苦于以下问题:Java JMXMPConnectorServer类的具体用法?Java JMXMPConnectorServer怎么用?Java JMXMPConnectorServer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JMXMPConnectorServer类属于javax.management.remote.jmxmp包,在下文中一共展示了JMXMPConnectorServer类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import javax.management.remote.jmxmp.JMXMPConnectorServer; //导入依赖的package包/类
@Override
public Void run() {
Runtime.getRuntime().addShutdownHook(new Thread(){
public void run() {
if(!servers.isEmpty()) {
SimpleLogger.log("Shutting down JMXMP Connector Servers");
for(final JMXMPConnectorServer server: servers) {
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@Override
public Void run() {
try { server.stop(); } catch (Exception x) {/* No Op */}
return null;
}
});
}
servers.clear();
}
}
});
return null;
}
示例2: testJMXMPTunnel
import javax.management.remote.jmxmp.JMXMPConnectorServer; //导入依赖的package包/类
/**
* Tests loading an array of SSHConnections from JSON and establishing a basic connection
* @throws Exception thrown on any error
*/
@SuppressWarnings("static-method")
@Test
public void testJMXMPTunnel() throws Exception {
System.clearProperty(SSHD_PORT_PROP);
final ApacheSSHDServer sshdServer = ApacheSSHDServer.getInstance();
final int[] ports = setLocalPorts();
System.setProperty(SSHD_PORT_PROP, "" + sshdServer.getPort());
final JMXMPConnectorServer jmxmp = JMXHelper.fireUpJMXMPServer(0);
final int remotePort = jmxmp.getAddress().getPort();
final String agentId = JMXHelper.getAgentId();
log("Actual Agent ID: [" + agentId + "]");
try {
final URL url = SSHConnectionTest.class.getClassLoader().getResource(TEST_JSON);
final SSHConnection[] connections = SSHTunnelManager.parseConnections(url);
log(Arrays.deepToString(connections));
for(int i = 0; i < connections.length; i++) {
connections[i].authenticate();
LocalPortForwarder lpf = (LocalPortForwarder)PrivateAccessor.invoke(connections[i], "createPortForward", new Object[]{0, "localhost", remotePort}, int.class, String.class, int.class);
final int localPort = lpf.getLocalPort();
final JMXConnector jmxConnector = JMXHelper.getJMXConnection("service:jmx:jmxmp://localhost:" + localPort, true, null);
final MBeanServerConnection server = jmxConnector.getMBeanServerConnection();
final String readAgentId = JMXHelper.getAgentId(server);
log("Agent ID: for [" + connections[i] + "] : [" + agentId + "]");
Assert.assertEquals("Mismatch on expected agent ids", agentId, readAgentId);
jmxConnector.close();
}
} finally {
jmxmp.stop();
sshdServer.stop(true);
System.clearProperty(SSHD_PORT_PROP);
}
}
示例3: testJMXMPProfiles
import javax.management.remote.jmxmp.JMXMPConnectorServer; //导入依赖的package包/类
public Result testJMXMPProfiles() throws Exception {
log.info(" ");
log.info("starat test JMXMPProfiles");
String[] profiles = { "JMXMP", "SASL", "TLS" };
for (int i = 0; i < profiles.length; i++) {
log.info("Create mbean server");
MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
JMXServiceURL url = new JMXServiceURL("service:jmx:jmxmp://");
log.info("Create JMX Service URL - " + url);
log.info("Create enviroment with profiles - " + profiles[i] );
HashMap enviroment = new HashMap();
enviroment.put("jmx.remote.profiles", profiles[i]);
// Create a JMXConnectorServer
log.info("Create JMXMPConnectorServer");
JMXMPConnectorServer server = new JMXMPConnectorServer(url,
enviroment, mbeanServer);
server.start();
log.info("Create JMXMPConnectorClient");
JMXMPConnector client = new JMXMPConnector(url, enviroment);
server.stop();
}
return result();
}