1 4 package com.tc.management.remote.protocol.terracotta; 5 6 import java.io.IOException ; 7 import java.net.MalformedURLException ; 8 import java.util.HashMap ; 9 import java.util.Map ; 10 11 import javax.management.remote.JMXConnector ; 12 import javax.management.remote.JMXConnectorProvider ; 13 import javax.management.remote.JMXServiceURL ; 14 import javax.management.remote.generic.GenericConnector; 15 16 import com.tc.net.protocol.tcm.MessageChannel; 17 18 public class ClientProvider implements JMXConnectorProvider { 19 20 public static final String JMX_MESSAGE_CHANNEL = "JmxMessageChannel"; 21 public static final String CONNECTION_LIST = "channelIdToMsgConnection"; 22 23 public JMXConnector newJMXConnector(final JMXServiceURL jmxserviceurl, final Map initialEnvironment) 24 throws IOException { 25 if (!jmxserviceurl.getProtocol().equals("terracotta")) { 26 MalformedURLException exception = new MalformedURLException ("Protocol not terracotta: " 27 + jmxserviceurl.getProtocol()); 28 throw exception; 29 } 30 final Map terracottaEnvironment = initialEnvironment != null ? new HashMap (initialEnvironment) : new HashMap (); 31 final MessageChannel channel = (MessageChannel) terracottaEnvironment.remove(JMX_MESSAGE_CHANNEL); 32 final TunnelingMessageConnection tmc = new TunnelingMessageConnection(channel, false); 33 final Map channelIdToMsgConnection = (Map ) terracottaEnvironment.remove(CONNECTION_LIST); 34 synchronized (channelIdToMsgConnection) { 35 channelIdToMsgConnection.put(channel.getChannelID(), tmc); 36 } 37 terracottaEnvironment.put(GenericConnector.MESSAGE_CONNECTION, tmc); 38 return new GenericConnector(terracottaEnvironment); 39 } 40 41 } 42 | Popular Tags |