KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webjmx > remoting > RemotingServer


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

8
9 package org.webjmx.remoting;
10
11 import java.io.*;
12 import java.net.*;
13
14 import javax.management.*;
15
16 // JDMK imports
17
import com.sun.jdmk.*;
18 import com.sun.jdmk.comm.*;
19
20
21 public class RemotingServer
22 {
23     private MBeanServer server;
24
25     public RemotingServer()
26     {
27         try { Trace.parseTraceProperties(); }
28         catch(IOException e) { e.printStackTrace(); }
29
30         server = MBeanServerFactory.createMBeanServer();
31
32         CommunicatorServer htmlAdaptor = new HtmlAdaptorServer();
33
34         try
35         {
36             ObjectName htmlAdaptorObjectName = null;
37             ObjectInstance htmlAdaptorInstance = server.registerMBean(htmlAdaptor, htmlAdaptorObjectName);
38             htmlAdaptor.start();
39     
40             CommunicatorServer rmiConnector = new RmiConnectorServer();
41
42             ObjectName rmiConnectorName = null;
43             ObjectInstance rmiConnectorInstance = server.registerMBean(rmiConnector, rmiConnectorName);
44     
45             rmiConnector.start();
46             System.out.println("started RemoteMBean server listening on port: " +rmiConnector.getPort());
47         }catch(Exception JavaDoc e)
48         {
49             e.printStackTrace();
50         }
51     }
52
53
54     public static void main(String JavaDoc[] args)
55     {
56         RemotingServer myBaseAgent = new RemotingServer();
57     }
58 }
59
Popular Tags