KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > examples > mbeans > iiop > IIOPServer


1 /*
2  * Copyright (C) The MX4J Contributors.
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 package mx4j.examples.mbeans.iiop;
9
10 import javax.management.MBeanServer JavaDoc;
11 import javax.management.MBeanServerFactory JavaDoc;
12 import javax.management.MBeanServerInvocationHandler JavaDoc;
13 import javax.management.ObjectName JavaDoc;
14
15 /**
16  * This example starts a RMI over IIOP server that listens for RMI clients to connect
17  * and exposes its functionalities via JMX.
18  * To be run, be sure to have started the tnameserv or the orbd utility on the port
19  * specified by {@link Hello#IIOP_JNDI_NAME}, with the following command:
20  * <pre>
21  * $JAVA_HOME/bin/orbd -ORBInitialPort 1900
22  * </pre>
23  *
24  * @version $Revision: 1.1 $
25  */

26 public class IIOPServer
27 {
28    public static void main(String JavaDoc[] args) throws Exception JavaDoc
29    {
30       MBeanServer JavaDoc server = MBeanServerFactory.newMBeanServer();
31
32       ObjectName JavaDoc name = new ObjectName JavaDoc("examples:type=iiop-remote");
33       HelloImpl remote = new HelloImpl();
34       server.registerMBean(remote, name);
35
36       HelloImplMBean managed = (HelloImplMBean)MBeanServerInvocationHandler.newProxyInstance(server, name, HelloImplMBean.class, false);
37       managed.start();
38    }
39 }
40
Popular Tags