1 23 24 38 39 package com.sun.enterprise.admin.monitor.registry.spi.reconfig; 40 41 import java.util.Iterator ; 42 import java.util.logging.Logger ; 43 import com.sun.enterprise.admin.monitor.registry.MonitoringLevel; 44 import com.sun.enterprise.admin.monitor.registry.MonitoredObjectType; 45 import com.sun.enterprise.admin.monitor.registry.StatsHolder; 46 47 import com.sun.enterprise.admin.monitor.registry.spi.ValueListMap; 48 import com.sun.enterprise.admin.monitor.registry.spi.MonitoringRegistrationHelper; 49 import com.sun.enterprise.admin.common.constant.AdminConstants; 50 51 59 class OrbChangeHandler implements ChangeHandler { 60 61 private final ChangeHandler successor; 62 private final ValueListMap listeners; 63 64 private static final Logger logger = Logger.getLogger(AdminConstants.kLoggerName); 65 66 OrbChangeHandler(ChangeHandler successor, ValueListMap listeners) { 67 this.successor = successor; 68 this.listeners = listeners; 69 } 70 71 public void handleChange(MonitoredObjectType t, MonitoringLevel from, MonitoringLevel to) { 72 if (isOrbType(t)) { 73 handleChange(from, to); 74 } 75 else { 76 successor.handleChange(t, from, to); 77 } 78 } 79 80 private boolean isOrbType(MonitoredObjectType t) { 81 return ( t == MonitoredObjectType.ORB || 82 t == MonitoredObjectType.CONNECTION_MANAGER); 83 } 84 85 private void handleChange(MonitoringLevel from, MonitoringLevel to) { 86 if (off2Low(from, to) || off2High(from, to)) { 87 notifyListeners(from, to); 88 registerMBeans(); 89 } 90 if (low2Off(from, to) || high2Off(from, to)) { 91 unregisterMBeans(); 92 notifyListeners(from, to); 93 } 94 if (low2High(from, to) || high2Low(from, to)) { 95 } 97 } 98 99 private void notifyListeners(MonitoringLevel from, MonitoringLevel to) { 100 logger.finer("DynamicReconfigurator: Now notifying the listeners for ORB stats --- from = " + from.toString() + " to = " + to.toString()); 101 } 102 103 private void registerMBeans() { 104 final MonitoringRegistrationHelper registryImpl = 105 (MonitoringRegistrationHelper) MonitoringRegistrationHelper.getInstance(); 106 108 final Iterator iter = registryImpl.getOrbNodes().iterator(); 110 while (iter.hasNext()) { 111 final StatsHolder c = (StatsHolder) iter.next(); 112 c.registerMBean(); 113 logger.finer("DynamicReconfigurator: Now Registering MBean for --- " + c.getName()); 114 } 115 } 116 117 private void unregisterMBeans() { 118 final MonitoringRegistrationHelper registryImpl = 119 (MonitoringRegistrationHelper) MonitoringRegistrationHelper.getInstance(); 120 122 final Iterator iter = registryImpl.getOrbNodes().iterator(); 123 while (iter.hasNext()) { 124 final StatsHolder c = (StatsHolder) iter.next(); 125 c.unregisterMBean(); 126 logger.finer("DynamicReconfigurator: Now UnRegistering MBean for --- " + c.getName()); 127 } 128 } 129 130 private boolean off2Low(MonitoringLevel from, MonitoringLevel to) { 131 return ( from == MonitoringLevel.OFF && to == MonitoringLevel.LOW ); 132 } 133 private boolean off2High(MonitoringLevel from, MonitoringLevel to) { 134 return ( from == MonitoringLevel.OFF && to == MonitoringLevel.HIGH ); 135 } 136 private boolean low2Off(MonitoringLevel from, MonitoringLevel to) { 137 return ( from == MonitoringLevel.LOW && to == MonitoringLevel.OFF); 138 } 139 private boolean high2Off(MonitoringLevel from, MonitoringLevel to) { 140 return ( from == MonitoringLevel.HIGH && to == MonitoringLevel.OFF ); 141 } 142 private boolean low2High(MonitoringLevel from, MonitoringLevel to) { 143 return ( from == MonitoringLevel.LOW && to == MonitoringLevel.HIGH); 144 } 145 private boolean high2Low(MonitoringLevel from, MonitoringLevel to) { 146 return ( from == MonitoringLevel.HIGH && to == MonitoringLevel.LOW ); 147 } 148 } 149 | Popular Tags |