1 23 package com.sun.enterprise.admin.wsmgmt.transform; 24 25 import java.util.Collection ; 26 import java.util.List ; 27 import java.util.Iterator ; 28 29 import com.sun.enterprise.admin.wsmgmt.config.spi.Constants; 30 import com.sun.enterprise.admin.wsmgmt.config.spi.ConfigFactory; 31 import com.sun.enterprise.admin.wsmgmt.config.spi.ConfigProvider; 32 import com.sun.enterprise.admin.wsmgmt.config.spi.WebServiceConfig; 33 import com.sun.enterprise.admin.wsmgmt.pool.spi.Pool; 34 import com.sun.enterprise.admin.wsmgmt.pool.impl.BoundedPool; 35 import com.sun.enterprise.admin.wsmgmt.filter.spi.Filter; 36 import com.sun.enterprise.admin.wsmgmt.filter.spi.FilterRegistry; 37 import com.sun.appserv.management.ext.wsmgmt.MessageTrace; 38 39 import java.util.logging.Logger ; 40 import java.util.logging.Level ; 41 import com.sun.logging.LogDomains; 42 import com.sun.enterprise.util.i18n.StringManager; 43 44 47 public class TransformHandler { 48 49 54 public TransformHandler(WebServiceConfig wsc, String appId) throws 55 TransformException { 56 57 _applicationId = appId; 58 _endpointId = wsc.getName(); 59 60 } 61 62 67 public TransformHandler(String endpoint, String appId) { 68 _applicationId = appId; 69 _endpointId = endpoint; 70 71 } 72 73 76 public Filter registerFilter(WebServiceConfig wsc) 77 throws TransformException { 78 79 _filter = new TransformFilter(_applicationId, wsc); 80 FilterRegistry fr = FilterRegistry.getInstance(); 81 String endpoint = getFQEndpointName(); 82 83 fr.registerFilter(Filter.PROCESS_REQUEST, endpoint, _filter); 85 fr.registerFilter(Filter.PROCESS_RESPONSE, endpoint, _filter); 86 return _filter; 87 } 88 89 92 private void registerFilter() { 93 94 _filter = new TransformFilter(_applicationId, _endpointId); 96 FilterRegistry fr = FilterRegistry.getInstance(); 97 String endpoint = getFQEndpointName(); 98 99 fr.registerFilter(Filter.PROCESS_REQUEST, endpoint, _filter); 101 fr.registerFilter(Filter.PROCESS_RESPONSE, endpoint, _filter); 102 } 103 104 107 void destroy() { 108 if (_filter != null) { 109 FilterRegistry fr = FilterRegistry.getInstance(); 110 String endpoint = getFQEndpointName(); 111 112 fr.unregisterFilter(Filter.PROCESS_REQUEST, endpoint, _filter); 114 fr.unregisterFilter(Filter.PROCESS_RESPONSE, endpoint, _filter); 115 _filter = null; 116 } 117 _logger.finer("Transform handler destroyed for " 118 + getEndpointName()); 119 } 120 121 124 void unregisterFilter(String appId, WebServiceConfig wsc) { 125 String fn = TransformFilter.getName(appId, wsc); 126 FilterRegistry fr = FilterRegistry.getInstance(); 127 String endpoint = getFQEndpointName(appId, wsc); 128 129 fr.unregisterFilterByName(Filter.PROCESS_REQUEST, endpoint, fn); 131 fr.unregisterFilterByName(Filter.PROCESS_RESPONSE, endpoint, fn); 132 _logger.finer("Transform handler destroyed for " 133 + getEndpointName()); 134 } 135 136 139 public Filter getFilter(String appId, WebServiceConfig wsc) { 140 FilterRegistry fr = FilterRegistry.getInstance(); 141 String endpoint = getFQEndpointName(appId, wsc); 142 143 _logger.finer("getFilter called for " 144 + getEndpointName()); 145 List filterList= fr.getFilters(Filter.PROCESS_REQUEST, endpoint); 146 if ( filterList == null) { 147 return null; 148 } 149 Iterator filterItr = filterList.iterator(); 150 if ( filterItr == null) { 151 return null; 152 } 153 while ( filterItr.hasNext()) { 154 Filter f = (Filter) filterItr.next(); 155 if ( f instanceof TransformFilter) { 156 return f; 157 } 158 } 159 return null; 160 } 161 162 167 String getEndpointName() { 168 return _endpointId; 169 } 170 171 176 String getFQEndpointName() { 177 return _applicationId + DELIM + _endpointId; 178 } 179 180 185 String getFQEndpointName(String appId, WebServiceConfig wsc) { 186 return appId + DELIM + wsc.getName(); 187 } 188 189 private TransformFilter _filter = null; 191 private String _endpointId = null; 192 private String _applicationId = null; 193 private static final String DELIM = "#"; 194 private static final Logger _logger = 195 Logger.getLogger(LogDomains.ADMIN_LOGGER); 196 private static final StringManager _stringMgr = 197 StringManager.getManager(TransformHandler.class); 198 } 199 | Popular Tags |