01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.management.remote.protocol.terracotta;
05:
06: import java.io.IOException;
07: import java.net.MalformedURLException;
08: import java.util.HashMap;
09: import java.util.Map;
10:
11: import javax.management.MBeanServer;
12: import javax.management.remote.JMXConnectorServer;
13: import javax.management.remote.JMXConnectorServerProvider;
14: import javax.management.remote.JMXServiceURL;
15: import javax.management.remote.generic.GenericConnectorServer;
16:
17: public class ServerProvider implements JMXConnectorServerProvider {
18:
19: public JMXConnectorServer newJMXConnectorServer(
20: final JMXServiceURL jmxServiceURL,
21: final Map initialEnvironment, final MBeanServer mBeanServer)
22: throws IOException {
23: if (!jmxServiceURL.getProtocol().equals("terracotta")) {
24: MalformedURLException exception = new MalformedURLException(
25: "Protocol not terracotta: "
26: + jmxServiceURL.getProtocol());
27: throw exception;
28: }
29: Map terracottaEnvironment = initialEnvironment != null ? new HashMap(
30: initialEnvironment)
31: : new HashMap();
32: terracottaEnvironment.put(
33: GenericConnectorServer.MESSAGE_CONNECTION_SERVER,
34: new TunnelingMessageConnectionServer(jmxServiceURL));
35: return new GenericConnectorServer(terracottaEnvironment,
36: mBeanServer);
37: }
38:
39: }
|