1 23 package com.sun.enterprise.admin.wsmgmt.msg; 24 25 import java.util.Map ; 26 import java.util.Collection ; 27 import java.util.ArrayList ; 28 import java.util.Hashtable ; 29 import java.util.Iterator ; 30 import com.sun.enterprise.admin.wsmgmt.config.spi.Constants; 31 import com.sun.enterprise.admin.wsmgmt.config.spi.ConfigFactory; 32 import com.sun.enterprise.admin.wsmgmt.config.spi.ConfigProvider; 33 import com.sun.enterprise.admin.wsmgmt.config.spi.WebServiceConfig; 34 35 import java.util.logging.Logger ; 36 import java.util.logging.Level ; 37 import com.sun.logging.LogDomains; 38 import com.sun.enterprise.util.i18n.StringManager; 39 40 43 class ApplicationMediator { 44 45 50 ApplicationMediator(String id) throws MessageTraceException { 51 52 _applicationId = id; 53 _endpoints = new Hashtable (); 54 55 try { 57 ConfigFactory cf = ConfigFactory.getConfigFactory(); 58 ConfigProvider cp = cf.getConfigProvider(); 59 WebServiceConfig[] wsc = cp.getWebserviceConfigs(id); 60 61 for (int i=0; i<wsc.length; i++) { 62 String mLevel = wsc[i].getMonitoringLevel(); 63 64 if (Constants.HIGH.equals(mLevel)) { 66 EndpointHandler eph = new EndpointHandler(wsc[i], id); 67 _endpoints.put(eph.getEndpointName(), eph); 68 } 69 } 70 } catch (Exception e) { 71 String msg=_stringMgr.getString("ApplicationMediator_ConfigEx",id); 72 throw new MessageTraceException(msg, e); 73 } 74 } 75 76 83 void setMessageHistorySize(String wsEndpoint, int size) { 84 EndpointHandler eph = (EndpointHandler) _endpoints.get(wsEndpoint); 85 if (eph != null) { 86 eph.setMessageHistorySize(size); 87 } 88 } 89 90 95 void disable(String wsEndpoint) { 96 EndpointHandler eph = (EndpointHandler) _endpoints.remove(wsEndpoint); 97 if (eph != null) { 98 eph.destroy(); 99 } 100 } 101 102 108 void enable(String wsEndpoint, int size) { 109 EndpointHandler eph = 110 new EndpointHandler(wsEndpoint, size, _applicationId); 111 _endpoints.put(wsEndpoint, eph); 112 } 113 114 119 boolean isEmpty() { 120 Collection c = _endpoints.values(); 121 return c.isEmpty(); 122 } 123 124 130 Collection getMessages(String wsEndpoint) { 131 EndpointHandler eph = (EndpointHandler) _endpoints.get(wsEndpoint); 132 if (eph != null) { 133 return eph.getMessages(); 134 } 135 return null; 136 } 137 138 143 Collection getMessages() { 144 145 Collection c = new ArrayList (); 146 Collection endpoints = _endpoints.values(); 147 for (Iterator iter=endpoints.iterator(); iter.hasNext();) { 148 EndpointHandler eph = (EndpointHandler) iter.next(); 149 if (eph != null) { 150 c.addAll( eph.getMessages() ); 151 } 152 } 153 154 return c; 155 } 156 157 160 void destroy() { 161 Collection endpoints = _endpoints.values(); 162 for (Iterator iter=endpoints.iterator(); iter.hasNext();) { 163 EndpointHandler eph = (EndpointHandler) iter.next(); 164 if (eph != null) { 165 eph.destroy(); 166 } 167 } 168 _endpoints.clear(); 169 _endpoints = null; 170 _logger.finer("Message trace mediator destroyed for " + _applicationId); 171 } 172 173 private Map _endpoints = null; 175 private String _applicationId = null; 176 private static final Logger _logger = 177 Logger.getLogger(LogDomains.ADMIN_LOGGER); 178 private static final StringManager _stringMgr = 179 StringManager.getManager(ApplicationMediator.class); 180 181 } 182 | Popular Tags |