KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > examples > tools > remote > hessian > ssl > 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.ssl;
10
11 import java.util.HashMap JavaDoc;
12 import java.util.Map JavaDoc;
13
14 import javax.management.MBeanServer JavaDoc;
15 import javax.management.MBeanServerFactory JavaDoc;
16 import javax.management.remote.JMXConnectorServer JavaDoc;
17 import javax.management.remote.JMXConnectorServerFactory JavaDoc;
18 import javax.management.remote.JMXServiceURL JavaDoc;
19
20 import mx4j.tools.remote.http.HTTPConnectorServer;
21
22 /**
23  * This example shows how to setup a JSR 160 connector server that uses Caucho's Hessian
24  * protocol over HTTPS as communication protocol with the client.
25  * <br />
26  * MX4J's implementation requires the hessian library version 3.0.8 and
27  * a servlet container to run. The default servlet container used is Jetty.
28  * To run this example, you need the following jars:
29  * <ul>
30  * <li>MX4J 3.x</li>
31  * <ul>
32  * <li>mx4j.jar</li>
33  * <li>mx4j-remote.jar</li>
34  * <li>mx4j-tools.jar</li>
35  * <li>mx4j-examples.jar</li>
36  * </ul>
37  * <li>Jetty 4.2.x or later</li>
38  * <ul>
39  * <li>org.mortbay.jetty.jar</li>
40  * <li>servlet.jar</li>
41  * <li>commons-logging.jar</li>
42  * </ul>
43  * <li>Hessian 3.0.8</li>
44  * <ul>
45  * <li>hessian-3.0.8.jar</li>
46  * </ul>
47  * </ul>
48  * Furthermore, you need a Jetty configuration file and a keystore
49  * (see the MX4J documentation on how to create these 2 files).
50  *
51  * @version : $Revision: 1.1 $
52  */

53 public class Server
54 {
55    public static void main(String JavaDoc[] args) throws Exception JavaDoc
56    {
57       // The MBeanServer
58
MBeanServer JavaDoc server = MBeanServerFactory.createMBeanServer();
59
60       // Pass null as the host name to tell JMXServiceURL to default to InetAddress.getLocalHost().getHostName()
61
JMXServiceURL JavaDoc url = new JMXServiceURL JavaDoc("hessian+ssl", null, 8443, "/hessianssl");
62
63       // Replace the value of the configuration with the file path of the configuration file
64
Map JavaDoc serverEnv = new HashMap JavaDoc();
65       serverEnv.put(HTTPConnectorServer.WEB_CONTAINER_CONFIGURATION, "<your-web-container-configuration>");
66       JMXConnectorServer JavaDoc connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, serverEnv, server);
67       connectorServer.start();
68
69       System.out.println("Server up and running " + connectorServer + " on " + url);
70    }
71 }
72
Popular Tags