public static void main(String[] args) throws Exception
{
// The address of the connector server
JMXServiceURL url = new JMXServiceURL("rmi", "localhost", 0, "/jndi/jmx");
// Create and connect the connector client
JMXConnector cntor = JMXConnectorFactory.connect(url, null);
// The connection represent, on client-side, the remote MBeanServer
MBeanServerConnection connection = cntor.getMBeanServerConnection();
// The listener that will receive notifications from a remote MBean
NotificationListener listener = new NotificationListener()
{
public void handleNotification(Notification notification, Object handback)
{
System.out.println(notification);
}
};
// The MBeanServerDelegate emits notifications about registration/unregistration of MBeans
ObjectName delegateName = ObjectName.getInstance("JMImplementation:type=MBeanServerDelegate");
connection.addNotificationListener(delegateName, listener, null, null);
// Give chance to the notification machinery to setup
Thread.sleep(1000);
// Now register a remote MBean, for example an MLet, so that the MBeanServerDelegate
// will emit notifications for its registration
ObjectName name = ObjectName.getInstance("examples:mbean=mlet");
// First notification
connection.createMBean(MLet.class.getName(), name, null);
// Second notification
connection.unregisterMBean(name);
}
Client.java 文件源码
java
阅读 51
收藏 0
点赞 0
评论 0
项目:cacheonix-core
作者:
评论列表
文章目录