1 23 24 package com.sun.enterprise.webservice.monitoring; 25 26 import javax.servlet.http.HttpServletRequest ; 27 28 import com.sun.xml.ws.spi.runtime.MessageContext; 29 import com.sun.xml.ws.spi.runtime.SOAPMessageContext; 30 import com.sun.xml.ws.spi.runtime.SystemHandlerDelegate; 31 32 37 public class JAXWSEndpointImpl extends EndpointImpl implements SystemHandlerDelegate { 38 39 SystemHandlerDelegate parent = null; 40 41 42 JAXWSEndpointImpl(String endpointSelector, EndpointType type) { 43 super(endpointSelector, type); 44 } 45 46 public boolean processRequest(MessageContext ctxt) throws Exception { 47 48 boolean status = true; 49 50 if(!(ctxt instanceof SOAPMessageContext)) { 51 return status; 52 } 53 SOAPMessageContext messageContext = (SOAPMessageContext)ctxt; 54 WebServiceEngineImpl wsEngine = WebServiceEngineImpl.getInstance(); 56 try { 57 if (parent!=null) { 58 status = parent.processRequest(ctxt); 59 } 60 61 if (!listeners.isEmpty() || wsEngine.hasGlobalMessageListener()) { 62 63 String messageID = (String ) messageContext.get(EndpointImpl.MESSAGE_ID); 64 65 if (messageID!=null) { 67 HttpServletRequest httpReq = (HttpServletRequest ) messageContext.get(MessageContext.SERVLET_REQUEST); 68 HttpRequestInfoImpl info = new HttpRequestInfoImpl(httpReq); 69 wsEngine.processRequest(messageID, messageContext, info); 70 } 71 72 if (!listeners.isEmpty()) { 74 MessageTraceImpl request = new MessageTraceImpl(); 76 request.setEndpoint(this); 77 request.setMessageContext(messageContext); 78 HttpServletRequest httpReq = (HttpServletRequest ) messageContext.get(MessageContext.SERVLET_REQUEST); 79 request.setTransportInfo(new HttpRequestInfoImpl(httpReq)); 80 messageContext.put(EndpointImpl.REQUEST_TRACE, request); 81 } 82 } 83 } catch(Exception e) { 84 wsEngine.sLogger.warning("Exception while tracing request : " + e.getMessage()); 85 throw e; 86 } 87 return status; 88 } 89 90 public void processResponse(MessageContext ctxt) throws Exception { 91 92 if(!(ctxt instanceof SOAPMessageContext)) { 93 return; 94 } 95 SOAPMessageContext messageContext = (SOAPMessageContext)ctxt; 96 WebServiceEngineImpl wsEngine = WebServiceEngineImpl.getInstance(); 98 try { 99 100 if (wsEngine.hasGlobalMessageListener() || !listeners.isEmpty()) { 101 102 String messageID = (String ) messageContext.get(EndpointImpl.MESSAGE_ID); 103 if (messageID!=null) { 105 wsEngine.processResponse(messageID, messageContext); 106 } 107 108 if (!listeners.isEmpty()) { 110 MessageTraceImpl response = new MessageTraceImpl(); 111 response.setEndpoint(this); 112 response.setMessageContext(messageContext); 113 for (MessageListener listener : listeners) { 114 listener.invocationProcessed((MessageTrace) messageContext.get(REQUEST_TRACE), response); 115 } 116 } 117 } 118 119 if (parent!=null) { 121 parent.processResponse(ctxt); 122 } 123 124 } catch(Exception e) { 125 wsEngine.sLogger.warning("Exception while tracing response : " + e.getMessage()); 126 throw e; 127 } 128 } 129 130 public void preInvokeEndpointHook(MessageContext messageContext) { 131 if (parent!=null) { 132 parent.preInvokeEndpointHook(messageContext); 133 } 134 } 135 136 public void setParent(SystemHandlerDelegate parent) { 137 this.parent = parent; 138 } 139 } 140 | Popular Tags |