1 23 24 30 31 32 package com.sun.enterprise.admin.monitor.registry.spi.reconfig; 33 import com.sun.enterprise.admin.event.MonitoringLevelChangeEvent; 34 import com.sun.enterprise.admin.event.MonitoringLevelChangeEventListener; 35 import com.sun.enterprise.admin.event.AdminEventListenerException; 36 37 import com.sun.enterprise.admin.monitor.registry.MonitoringLevel; 38 import com.sun.enterprise.admin.monitor.registry.MonitoredObjectType; 39 46 public class MonitoringConfigChangeListener implements MonitoringLevelChangeEventListener { 47 48 private final ChangeHandler delegate; 49 public MonitoringConfigChangeListener(ChangeHandler delegate) { 50 this.delegate = delegate; 51 } 52 public synchronized void monitoringLevelChanged( 53 MonitoringLevelChangeEvent event) 54 throws AdminEventListenerException { 55 56 final String component = event.getComponentName(); 59 final String from = event.getOldMonitoringLevel(); 60 final String to = event.getNewMonitoringLevel(); 61 62 MonitoringThreadContext.setEventToThreadLocal(event); 64 65 handleAllAffectedTypes(component, from, to); 66 67 MonitoringThreadContext.removeEventFromThreadLocal(); 69 } 70 71 private void handleAllAffectedTypes(String component, String from, String to) { 72 final MonitoredObjectType[] types = name2Types(component); 73 final MonitoringLevel oLevel = MonitoringLevel.instance(from); 74 final MonitoringLevel nLevel = MonitoringLevel.instance(to); 75 for (int i = 0 ; i < types.length ; i++) { 76 delegate.handleChange(types[i], oLevel, nLevel); 77 } 78 } 79 80 private MonitoredObjectType[] name2Types(String component) { 81 MonitoredObjectType[] types = new MonitoredObjectType[0]; if (EJB_CONTAINER.equals(component)) { 83 types = MonitoredObjectType.EJB_TYPES; 84 } 85 else if (WEB_CONTAINER.equals(component)) { 86 types = new MonitoredObjectType[1]; 87 types[0] = MonitoredObjectType.SERVLET; 88 } 89 else if (THREAD_POOL.equals(component)) { 90 types = new MonitoredObjectType[1]; 91 types[0] = MonitoredObjectType.THREAD_POOL; 92 } 93 else if (ORB.equals(component)) { 94 types = new MonitoredObjectType[1]; 95 types[0] = MonitoredObjectType.ORB; 96 } 97 else if (HTTP_SERVICE.equals(component)) { 98 types = MonitoredObjectType.HTTP_SERVICE_TYPES; 99 } 100 else if (TRANSACTION_SERVICE.equals(component)) { 101 types = new MonitoredObjectType[1]; 102 types[0] = MonitoredObjectType.TRANSACTION_SERVICE; 103 } 104 else if (JDBC_CONN_POOL.equals(component)) { 105 types = new MonitoredObjectType[1]; 106 types[0] = MonitoredObjectType.JDBC_CONN_POOL; 107 } 108 else if (CONNECTOR_SERVICE.equals(component)) { 109 types = new MonitoredObjectType[1]; 110 types[0] = MonitoredObjectType.CONNECTOR_SERVICE; 111 } 112 else if (JVM.equals(component)) { 113 types = new MonitoredObjectType[1]; 114 types[0] = MonitoredObjectType.JVM; 115 } else if (WEBSERVICE_ENDPOINT.equals(component)) { 116 types = new MonitoredObjectType[1]; 117 types[0] = MonitoredObjectType.WEBSERVICE_ENDPOINT; 118 } 119 135 return ( types ); 136 } 137 138 143 public static final String EJB_CONTAINER = "ejb-container"; 144 public static final String WEB_CONTAINER = "web-container"; 145 public static final String THREAD_POOL = "thread-pool"; 146 public static final String ORB = "orb"; 147 public static final String TRANSACTION_SERVICE = "transaction-service"; 148 public static final String HTTP_SERVICE = "http-service"; 149 public static final String JDBC_CONN_POOL = "jdbc-connection-pool"; 150 public static final String CONNECTOR_CONN_POOL = "connector-connection-pool"; 151 public static final String CONNECTOR_SERVICE = "connector-service"; 152 public static final String JMS_SERVICE = "jms-service"; 153 public static final String JNDI = "jndi"; 154 public static final String JVM = "jvm"; 155 public static final String WEBSERVICE_ENDPOINT = "webservice_endpoint"; 156 157 } 158 | Popular Tags |