1 23 package com.sun.enterprise.admin.wsmgmt.msg; 24 25 import java.util.Collection ; 26 import com.sun.enterprise.admin.wsmgmt.config.spi.Constants; 27 import com.sun.enterprise.admin.wsmgmt.config.spi.ConfigFactory; 28 import com.sun.enterprise.admin.wsmgmt.config.spi.ConfigProvider; 29 import com.sun.enterprise.admin.wsmgmt.config.spi.WebServiceConfig; 30 import com.sun.enterprise.admin.wsmgmt.pool.spi.Pool; 31 import com.sun.enterprise.admin.wsmgmt.pool.impl.BoundedPool; 32 import com.sun.enterprise.admin.wsmgmt.filter.spi.Filter; 33 import com.sun.enterprise.admin.wsmgmt.filter.spi.FilterRegistry; 34 import com.sun.appserv.management.ext.wsmgmt.MessageTrace; 35 36 import java.util.logging.Logger ; 37 import java.util.logging.Level ; 38 import com.sun.logging.LogDomains; 39 import com.sun.enterprise.util.i18n.StringManager; 40 41 44 class EndpointHandler { 45 46 51 EndpointHandler(WebServiceConfig wsc, String appId) { 52 53 _applicationId = appId; 54 _endpointId = wsc.getName(); 55 String mLevel = wsc.getMonitoringLevel(); 56 57 if (Constants.HIGH.equals(mLevel)) { 59 _pool = new BoundedPool(wsc.getName(), wsc.getMaxHistorySize()); 60 registerFilter(); 61 } 62 } 63 64 70 EndpointHandler(String endpoint, int size, String appId) { 71 _applicationId = appId; 72 _endpointId = endpoint; 73 _pool = new BoundedPool(endpoint, size); 74 75 registerFilter(); 76 } 77 78 81 private void registerFilter() { 82 83 _filter = new MessageFilter(_applicationId, _endpointId, this); 85 FilterRegistry fr = FilterRegistry.getInstance(); 86 String endpoint = getFQEndpointName(); 87 88 fr.registerFilter(Filter.PROCESS_REQUEST, endpoint, _filter); 90 fr.registerFilter(Filter.PROCESS_RESPONSE, endpoint, _filter); 91 fr.registerFilter(Filter.POST_PROCESS_RESPONSE, endpoint, _filter); 92 } 93 94 100 void setMessageHistorySize(int size) { 101 if (_pool != null) { 102 _pool.resize(size); 103 _logger.fine("Set message history size to " + size 104 + " for " + getEndpointName()); 105 } 106 } 107 108 111 void destroy() { 112 if (_pool != null) { 113 _pool.clear(); 114 _pool = null; 115 } 116 117 if (_filter != null) { 118 FilterRegistry fr = FilterRegistry.getInstance(); 119 String endpoint = getFQEndpointName(); 120 121 fr.unregisterFilter(Filter.PROCESS_REQUEST, endpoint, _filter); 123 fr.unregisterFilter(Filter.PROCESS_RESPONSE, endpoint, _filter); 124 fr.unregisterFilter(Filter.POST_PROCESS_RESPONSE, endpoint, _filter); 125 _filter = null; 126 } 127 _logger.finer("Message trace handler destroyed for " 128 + getEndpointName()); 129 } 130 131 136 Collection getMessages() { 137 return _pool.values(); 138 } 139 140 145 void addMessage(MessageTrace msgTrace) { 146 _pool.put(msgTrace.getMessageID(), msgTrace); 147 } 148 149 154 String getEndpointName() { 155 return _endpointId; 156 } 157 158 163 String getFQEndpointName() { 164 return _applicationId + DELIM + _endpointId; 165 } 166 167 private MessageFilter _filter = null; 169 private Pool _pool = null; 170 private String _endpointId = null; 171 private String _applicationId = null; 172 private static final String DELIM = "#"; 173 private static final Logger _logger = 174 Logger.getLogger(LogDomains.ADMIN_LOGGER); 175 private static final StringManager _stringMgr = 176 StringManager.getManager(EndpointHandler.class); 177 } 178 | Popular Tags |