KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > examples > tools > remote > hessian > Server


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
9 package mx4j.examples.tools.remote.hessian;
10
11 import javax.management.MBeanServer JavaDoc;
12 import javax.management.MBeanServerFactory JavaDoc;
13 import javax.management.remote.JMXConnectorServer JavaDoc;
14 import javax.management.remote.JMXConnectorServerFactory JavaDoc;
15 import javax.management.remote.JMXServiceURL JavaDoc;
16
17 /**
18  * This example shows how to setup a JSR 160 connector server that uses
19  * Caucho's Hessian protocol.
20  * <br />
21  * MX4J's implementation requires the hessian library version 3.0.8 and
22  * a servlet container to run. The default servlet container used is Jetty.
23  * To run this example, you need the following jars:
24  * <ul>
25  * <li>MX4J</li>
26  * <ul>
27  * <li>mx4j.jar</li>
28  * <li>mx4j-remote.jar</li>
29  * <li>mx4j-tools.jar</li>
30  * <li>mx4j-examples.jar</li>
31  * </ul>
32  * <li>Jetty 4.2.x or later</li>
33  * <ul>
34  * <li>org.mortbay.jetty.jar</li>
35  * <li>servlet.jar</li>
36  * <li>commons-logging.jar</li>
37  * </ul>
38  * <li>Hessian 3.0.8</li>
39  * <ul>
40  * <li>hessian-3.0.8.jar</li>
41  * </ul>
42  * </ul>
43  *
44  * @version : $Revision: 1.1 $
45  */

46 public class Server
47 {
48    public static void main(String JavaDoc[] args) throws Exception JavaDoc
49    {
50       // The MBeanServer
51
MBeanServer JavaDoc server = MBeanServerFactory.createMBeanServer();
52
53       // Pass null as the host name to tell JMXServiceURL to default to InetAddress.getLocalHost().getHostName()
54
JMXServiceURL JavaDoc url = new JMXServiceURL JavaDoc("hessian", null, 8080, "/hessian");
55
56       JMXConnectorServer JavaDoc connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
57       connectorServer.start();
58
59       System.out.println("Server up and running " + connectorServer + " on " + url);
60    }
61 }
62
Popular Tags