KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > tools > remote > http > HTTPConnectionManager


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.tools.remote.http;
10
11 import java.io.IOException JavaDoc;
12 import java.util.Map JavaDoc;
13 import javax.management.MBeanServerConnection JavaDoc;
14 import javax.security.auth.Subject JavaDoc;
15
16 import mx4j.remote.DefaultRemoteNotificationServerHandler;
17 import mx4j.remote.RemoteNotificationServerHandler;
18 import mx4j.tools.remote.AbstractConnectionManager;
19 import mx4j.tools.remote.AbstractJMXConnectorServer;
20 import mx4j.tools.remote.Connection;
21
22 /**
23  * @version $Revision: 1.4 $
24  */

25 public class HTTPConnectionManager extends AbstractConnectionManager
26 {
27    private final MBeanServerConnection JavaDoc mbeanServerConnection;
28    private final String JavaDoc protocol;
29
30    public HTTPConnectionManager(AbstractJMXConnectorServer server, String JavaDoc protocol, Map JavaDoc environment)
31    {
32       super(server, environment);
33       this.mbeanServerConnection = server.getMBeanServer();
34       this.protocol = protocol;
35    }
36
37    public String JavaDoc getProtocol()
38    {
39       return protocol;
40    }
41
42    protected Connection JavaDoc doConnect(String JavaDoc connectionId, Subject JavaDoc subject) throws IOException JavaDoc
43    {
44       RemoteNotificationServerHandler notificationHandler = new DefaultRemoteNotificationServerHandler(getEnvironment());
45       HTTPConnection invoker = new HTTPServerInvoker(mbeanServerConnection, notificationHandler);
46       HTTPConnection subjectInvoker = HTTPSubjectInvoker.newInstance(invoker, subject, getSecurityContext(), getEnvironment());
47       Connection JavaDoc handler = new HTTPConnectionHandler(subjectInvoker, this, connectionId);
48       return handler;
49    }
50
51    /**
52     * HTTPConnectionManager does not really manages connections,
53     * so this method does nothing by default
54     */

55    protected void doClose() throws IOException JavaDoc
56    {
57    }
58
59    /**
60     * HTTPConnectionManager does not really manages connections,
61     * so this method does nothing by default
62     */

63    protected void doCloseConnection(Connection JavaDoc connection) throws IOException JavaDoc
64    {
65    }
66 }
67
Popular Tags