01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package mx4j.examples.mbeans.rmi;
10:
11: import javax.management.MBeanServer;
12: import javax.management.MBeanServerFactory;
13: import javax.management.MBeanServerInvocationHandler;
14: import javax.management.ObjectName;
15:
16: /**
17: * This example starts a RMI over IIOP server that listens for RMI clients to connect
18: * and exposes its functionalities via JMX.
19: * To be run, be sure to have started the rmiregistry utility on the port
20: * specified by {@link MyRemoteService#JNDI_NAME}, with the following command:
21: * <pre>
22: * $JAVA_HOME/bin/rmiregistry 1099
23: * </pre>
24: *
25: * @version $Revision: 1.1 $
26: */
27: public class Server {
28: public static void main(String[] args) throws Exception {
29: MBeanServer server = MBeanServerFactory.createMBeanServer();
30:
31: ObjectName name = new ObjectName("examples:type=remote");
32: MyRemoteServiceObject remote = new MyRemoteServiceObject();
33: server.registerMBean(remote, name);
34:
35: MyRemoteServiceObjectMBean managed = (MyRemoteServiceObjectMBean) MBeanServerInvocationHandler
36: .newProxyInstance(server, name,
37: MyRemoteServiceObjectMBean.class, false);
38: managed.start();
39: }
40: }
|