[Ejtools-cvs] applications/jmx.browser/src/test/test/jmx/browser/mx4j RemotingClient.java,NONE,1.1 R
Brought to you by:
letiemble
From: <let...@us...> - 2003-12-14 08:38:21
|
Update of /cvsroot/ejtools/applications/jmx.browser/src/test/test/jmx/browser/mx4j In directory sc8-pr-cvs1:/tmp/cvs-serv11709/jmx.browser/src/test/test/jmx/browser/mx4j Added Files: RemotingClient.java RemotingServer.java Log Message: Add more javadocs. Adjust some things. --- NEW FILE: RemotingClient.java --- /* * Copyright (C) MX4J. * All rights reserved. * * This software is distributed under the terms of the MX4J License version 1.0. * See the terms of the MX4J License in the documentation provided with this software. */ package test.jmx.browser.mx4j; import javax.management.remote.JMXServiceURL; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.MBeanServerConnection; import javax.management.ObjectName; import javax.management.NotificationListener; import javax.management.Notification; /** * TODO: JAVADOCS on usage !!! * @author <a href="mailto:bio...@us...">Simone Bordet</a> * @version $Revision: 1.1 $ */ public class RemotingClient { public static void main(String[] args) throws Exception { JMXServiceURL url = new JMXServiceURL("rmi", "localhost", 0, "/jndi/jmx"); JMXConnector cntor = JMXConnectorFactory.connect(url, null); MBeanServerConnection connection = cntor.getMBeanServerConnection(); // The MBeanServerDelegate emits notifications about registration/unregistration of MBeans ObjectName delegateName = new ObjectName("JMImplementation:type=MBeanServerDelegate"); NotificationListener listener = new NotificationListener() { public void handleNotification(Notification notification, Object handback) { System.out.println(notification); } }; connection.addNotificationListener(delegateName, listener, null, null); } } --- NEW FILE: RemotingServer.java --- package test.jmx.browser.mx4j; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.management.remote.JMXConnectorServer; import javax.management.remote.JMXConnectorServerFactory; import javax.management.remote.JMXServiceURL; import mx4j.tools.naming.NamingService; public class RemotingServer { public static void main(String[] args) throws Exception { JMXServiceURL url = new JMXServiceURL("rmi", "localhost", 0, "/jndi/jmx"); System.out.println("Path = "+url.toString()); JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, null); ObjectName cntorServerName = ObjectName.getInstance(":service=" + JMXConnectorServer.class.getName() + ",protocol=" + url.getProtocol()); MBeanServer server = MBeanServerFactory.createMBeanServer("remote.notification.example"); server.registerMBean(cntorServer, cntorServerName); NamingService naming = new NamingService(); ObjectName namingName = new ObjectName(":service=" + NamingService.class.getName()); server.registerMBean(naming, namingName); NamingService naming2 = new NamingService(); ObjectName namingName2 = new ObjectName(":type=" + NamingService.class.getName()); server.registerMBean(naming2, namingName2); naming.start(); cntorServer.start(); System.out.println("Server up and running"); } } |