public static void main(String[] args) throws Exception
{
// Replace the value with the file path of your keystore.
// IMPORTANT: this should NOT be done in production environments, it is shown here just as an example.
System.setProperty("javax.net.ssl.trustStore", "<your-keystore>");
// This JMXServiceURL works only if the connector server is on the same host of
// the connector. If this is not the case, set the correct host name.
JMXServiceURL address = new JMXServiceURL("hessian+ssl", null, 8443, "/hessianssl");
// Connect a JSR 160 JMXConnector to the server side
JMXConnector connector = JMXConnectorFactory.connect(address);
// Retrieve an MBeanServerConnection that represent the MBeanServer
// the remote connector server is bound to
MBeanServerConnection connection = connector.getMBeanServerConnection();
// Call the server side as if it is a local MBeanServer
ObjectName delegateName = ObjectName.getInstance("JMImplementation:type=MBeanServerDelegate");
Object proxy = MBeanServerInvocationHandler.newProxyInstance(connection, delegateName, MBeanServerDelegateMBean.class, true);
MBeanServerDelegateMBean delegate = (MBeanServerDelegateMBean)proxy;
System.out.println(delegate.getImplementationVendor() + " is cool !");
// Register an MBean, and get notifications via the Hessian protocol
connection.addNotificationListener(delegateName, new NotificationListener()
{
public void handleNotification(Notification notification, Object handback)
{
System.out.println("Got the following notification: " + notification);
}
}, null, null);
ObjectName timerName = ObjectName.getInstance("services:type=Timer");
connection.createMBean(Timer.class.getName(), timerName, null);
// Unregistering the MBean to get another notification
connection.unregisterMBean(timerName);
// Allow the unregistration notification to arrive before killing this JVM
Thread.sleep(1000);
connector.close();
}
Client.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:cacheonix-core
作者:
评论列表
文章目录