1 23 package com.sun.enterprise.management.support; 24 25 import java.util.Hashtable ; 26 import java.util.Map ; 27 import javax.management.JMException ; 28 import javax.management.MBeanServer ; 29 import javax.management.ObjectName ; 30 import javax.management.Notification ; 31 import javax.management.NotificationListener ; 32 import javax.management.AttributeChangeNotification ; 33 34 import static com.sun.appserv.management.base.AMX.J2EE_TYPE_KEY; 35 import static com.sun.appserv.management.base.AMX.NAME_KEY; 36 import static com.sun.appserv.management.base.AMX.JMX_DOMAIN; 37 import static com.sun.appserv.management.base.XTypes.LOAD_BALANCER; 38 import static com.sun.appserv.management.base.XTypes.LOAD_BALANCER_CONFIG; 39 import static com.sun.appserv.management.base.XTypes.LOAD_BALANCER_MONITOR; 40 import static com.sun.appserv.management.base.XTypes.LB_CONFIG; 41 42 import com.sun.enterprise.management.support.AMXServerLogger; 43 import com.sun.enterprise.management.support.AMXMBeanRootLogger; 44 45 import com.sun.appserv.management.config.LoadBalancerConfig; 46 import com.sun.appserv.management.config.LBConfig; 47 import com.sun.appserv.management.client.ProxyFactory; 48 import com.sun.appserv.management.monitor.LoadBalancerMonitor; 49 import com.sun.appserv.management.base.Util; 50 51 55 public final class LBDeregistrationUtil { 56 57 private MBeanServer mbs = null; 58 private Map <String , NotificationListener > mLBConfigListenersMap = null; 59 private static LBDeregistrationUtil mUtil = null; 60 61 private LBDeregistrationUtil(MBeanServer mbs) { 62 mLBConfigListenersMap = new Hashtable <String , NotificationListener >(); 63 this.mbs=mbs; 64 } 65 66 public static LBDeregistrationUtil getInstance(MBeanServer mbs) { 67 if (mUtil == null) mUtil = new LBDeregistrationUtil(mbs); 68 return mUtil; 69 } 70 71 public LoadBalancerMonitor fetchLBMonitoringRoot( 72 String loadBalancerName) throws JMException { 73 74 ObjectName loadBalancerMonitorObjName = 75 new ObjectName (JMX_DOMAIN + ":" + J2EE_TYPE_KEY + "=" + 76 LOAD_BALANCER_MONITOR + "," + NAME_KEY + "=" + loadBalancerName); 77 LoadBalancerMonitor loadBalancerMonitor = 78 ProxyFactory.getInstance(mbs).getProxy(loadBalancerMonitorObjName, LoadBalancerMonitor.class); 79 80 return loadBalancerMonitor; 81 } 82 83 public void addLBConfigListener(String loadBalancerName, 84 NotificationListener nl, LBConfig lbConfig) { 85 lbConfig.addNotificationListener(nl, null, null); 86 mLBConfigListenersMap.put(loadBalancerName, nl); 87 } 88 89 public void removeLBConfigListener(String loadBalancerName, LBConfig lbConfig) 90 throws JMException { 91 lbConfig.removeNotificationListener( 92 (NotificationListener )mLBConfigListenersMap.get(loadBalancerName)); 93 mLBConfigListenersMap.remove(loadBalancerName); 94 } 95 } | Popular Tags |