KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > management > remote > protocol > terracotta > ServerProvider


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.management.remote.protocol.terracotta;
5
6 import java.io.IOException JavaDoc;
7 import java.net.MalformedURLException JavaDoc;
8 import java.util.HashMap JavaDoc;
9 import java.util.Map JavaDoc;
10
11 import javax.management.MBeanServer JavaDoc;
12 import javax.management.remote.JMXConnectorServer JavaDoc;
13 import javax.management.remote.JMXConnectorServerProvider JavaDoc;
14 import javax.management.remote.JMXServiceURL JavaDoc;
15 import javax.management.remote.generic.GenericConnectorServer;
16
17 public class ServerProvider implements JMXConnectorServerProvider JavaDoc {
18
19   public JMXConnectorServer JavaDoc newJMXConnectorServer(final JMXServiceURL JavaDoc jmxServiceURL, final Map JavaDoc initialEnvironment,
20                                                   final MBeanServer JavaDoc mBeanServer) throws IOException JavaDoc {
21     if (!jmxServiceURL.getProtocol().equals("terracotta")) {
22       MalformedURLException JavaDoc exception = new MalformedURLException JavaDoc("Protocol not terracotta: "
23                                                                   + jmxServiceURL.getProtocol());
24       throw exception;
25     }
26     Map JavaDoc terracottaEnvironment = initialEnvironment != null ? new HashMap JavaDoc(initialEnvironment) : new HashMap JavaDoc();
27     terracottaEnvironment.put(GenericConnectorServer.MESSAGE_CONNECTION_SERVER,
28                               new TunnelingMessageConnectionServer(jmxServiceURL));
29     return new GenericConnectorServer(terracottaEnvironment, mBeanServer);
30   }
31
32 }
33
Popular Tags