1 23 24 package com.sun.enterprise.webservice.spi; 25 26 import java.util.ArrayList ; 27 import java.util.Iterator ; 28 import java.util.logging.Level ; 29 30 import javax.xml.namespace.QName ; 31 import javax.xml.ws.Dispatch; 32 import javax.xml.ws.Service; 33 import javax.xml.ws.handler.HandlerResolver; 34 import javax.xml.bind.JAXBContext; 35 36 import com.sun.enterprise.deployment.ServiceReferenceDescriptor; 37 import com.sun.enterprise.webservice.ServiceRefDescUtil; 38 import com.sun.enterprise.webservice.WsUtil; 39 40 public class ServiceDelegateImpl extends javax.xml.ws.spi.ServiceDelegate { 41 42 private javax.xml.ws.spi.ServiceDelegate delegate; 43 private ArrayList <InvInterfaceCreationListener> listeners = new ArrayList (); 44 private ServiceReferenceDescriptor serviceRef; 45 46 public ServiceDelegateImpl(javax.xml.ws.spi.ServiceDelegate delegate) { 47 this.delegate = delegate; 48 serviceRef = ServiceRefDescUtil.getReference(); 49 } 50 51 79 @Override 80 public <T> T getPort(QName portName, 81 Class <T> serviceEndpointInterface) { 82 T port = delegate.getPort(portName, serviceEndpointInterface); 83 portCreated(port, serviceEndpointInterface); 84 return port; 85 } 86 87 109 public <T> T getPort(Class <T> serviceEndpointInterface) { 110 T port = delegate.getPort(serviceEndpointInterface); 111 portCreated(port, serviceEndpointInterface); 112 return port; 113 } 114 115 131 public void addPort(QName portName, String bindingId, 132 String endpointAddress) { 133 delegate.addPort(portName, bindingId, endpointAddress); 134 } 135 136 156 public <T> Dispatch<T> createDispatch(QName portName, Class <T> type, Service.Mode mode) { 157 Dispatch<T> dispatch = delegate.createDispatch(portName, type, mode); 158 dispatchCreated(dispatch, type); 159 return dispatch; 160 } 161 162 180 public Dispatch<Object > createDispatch(QName portName, 181 JAXBContext context, Service.Mode mode) { 182 183 Dispatch<Object > dispatch = delegate.createDispatch(portName, context, mode); 184 dispatchCreated(dispatch, Object .class); 185 return dispatch; 186 187 } 188 189 190 193 public QName getServiceName() { 194 return delegate.getServiceName(); 195 } 196 197 206 public Iterator <javax.xml.namespace.QName > getPorts() { 207 return delegate.getPorts(); 208 } 209 210 215 public java.net.URL getWSDLDocumentLocation() { 216 return delegate.getWSDLDocumentLocation(); 217 } 218 219 226 public HandlerResolver getHandlerResolver() { 227 return delegate.getHandlerResolver(); 228 } 229 230 243 public void setHandlerResolver(HandlerResolver handlerResolver) { 244 delegate.setHandlerResolver(handlerResolver); 245 } 246 247 258 public java.util.concurrent.Executor getExecutor() { 259 return delegate.getExecutor(); 260 } 261 262 277 public void setExecutor(java.util.concurrent.Executor executor) { 278 delegate.setExecutor(executor); 279 } 280 281 282 283 286 private <T> void portCreated(T port, Class <T> serviceEndpointInterface) { 287 for (InvInterfaceCreationListener listener : listeners) { 288 try { 289 listener.portCreated(port, serviceEndpointInterface); 290 } catch(Throwable t) { 291 WsUtil.getDefaultLogger().severe("Exception " 292 + t.getMessage() + " in portCreationListener : " + listener); 293 WsUtil.getDefaultLogger().log(Level.FINE, t.getMessage(), t); 294 } 295 } 296 } 297 298 302 public void addListener(InvInterfaceCreationListener listener) { 303 listeners.add(listener); 304 } 305 306 309 private <T> void dispatchCreated(Dispatch<T> dispatch, Class <T> serviceEndpointInterface) { 310 for (InvInterfaceCreationListener listener : listeners) { 311 try { 312 listener.dispatchCreated(dispatch, serviceEndpointInterface); 313 } catch(Throwable t) { 314 WsUtil.getDefaultLogger().severe("Exception " 315 + t.getMessage() + " in dispatchCreationListener : " + listener); 316 WsUtil.getDefaultLogger().log(Level.FINE, t.getMessage(), t); 317 } 318 } 319 } 320 321 325 public ServiceReferenceDescriptor getServiceReference() { 326 return serviceRef; 327 } 328 329 } 330 | Popular Tags |