KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > jmx > browser > mx4j > RemotingClient


1 /*
2  * Copyright (C) MX4J.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package test.jmx.browser.mx4j;
10
11 import javax.management.remote.JMXServiceURL JavaDoc;
12 import javax.management.remote.JMXConnector JavaDoc;
13 import javax.management.remote.JMXConnectorFactory JavaDoc;
14 import javax.management.MBeanServerConnection JavaDoc;
15 import javax.management.ObjectName JavaDoc;
16 import javax.management.NotificationListener JavaDoc;
17 import javax.management.Notification JavaDoc;
18
19 /**
20  * TODO: JAVADOCS on usage !!!
21  * @author <a HREF="mailto:biorn_steedom@users.sourceforge.net">Simone Bordet</a>
22  * @version $Revision: 1.1 $
23  */

24 public class RemotingClient
25 {
26    public static void main(String JavaDoc[] args) throws Exception JavaDoc
27    {
28       JMXServiceURL JavaDoc url = new JMXServiceURL JavaDoc("rmi", "localhost", 0, "/jndi/jmx");
29
30       JMXConnector JavaDoc cntor = JMXConnectorFactory.connect(url, null);
31
32       MBeanServerConnection JavaDoc connection = cntor.getMBeanServerConnection();
33
34       // The MBeanServerDelegate emits notifications about registration/unregistration of MBeans
35
ObjectName JavaDoc delegateName = new ObjectName JavaDoc("JMImplementation:type=MBeanServerDelegate");
36
37       NotificationListener JavaDoc listener = new NotificationListener JavaDoc()
38       {
39          public void handleNotification(Notification JavaDoc notification, Object JavaDoc handback)
40          {
41             System.out.println(notification);
42          }
43       };
44
45       connection.addNotificationListener(delegateName, listener, null, null);
46    }
47 }
48
Popular Tags