1 9 package org.jboss.mx.remoting; 10 11 import java.util.Collections ; 12 import java.util.HashMap ; 13 import java.util.Map ; 14 import javax.management.MBeanServer ; 15 import org.jboss.logging.Logger; 16 import org.jboss.remoting.InvokerLocator; 17 18 25 public class MBeanServerRegistry 26 { 27 private static final Logger log = Logger.getLogger(MBeanServerRegistry.class.getName()); 28 29 private static final Map serversById = Collections.synchronizedMap(new HashMap ()); 30 private static final Map serversByLocator = Collections.synchronizedMap(new HashMap ()); 31 32 38 public static final boolean isMBeanServerRegistered(String id) 39 { 40 return getMBeanServerFor(id) != null; 41 } 42 43 49 public static final MBeanServer getMBeanServerFor(String id) 50 { 51 return (MBeanServer ) serversById.get(id); 52 } 53 54 60 public static final boolean isMBeanServerRegistered(InvokerLocator locator) 61 { 62 return getMBeanServerFor(locator) != null; 63 } 64 65 71 public static final MBeanServer getMBeanServerFor(InvokerLocator locator) 72 { 73 return (MBeanServer ) serversByLocator.get(locator); 74 } 75 76 static synchronized void register(MBeanServer server, MBeanServerClientInvokerProxy proxy) 77 { 78 String serverid = proxy.getServerId(); 79 serversById.put(serverid, server); 80 serversByLocator.put(proxy.getLocator(), server); 81 if(log.isTraceEnabled()) 82 { 83 log.trace("register called with proxy: " + proxy + " and serverid: " + serverid); 84 } 85 } 86 87 static synchronized void unregister(MBeanServerClientInvokerProxy proxy) 88 { 89 String serverid = proxy.getServerId(); 90 serversById.remove(serverid); 91 serversByLocator.remove(proxy.getLocator()); 92 if(log.isTraceEnabled()) 93 { 94 log.trace("unregister called with proxy: " + proxy + " and serverid: " + serverid); 95 } 96 } 97 } 98 | Popular Tags |