1 23 24 package com.sun.enterprise.webservice; 25 26 import javax.servlet.*; 27 import javax.servlet.http.*; 28 29 import com.sun.xml.rpc.spi.JaxRpcObjectFactory; 30 import com.sun.xml.rpc.spi.runtime.ServletDelegate; 31 import com.sun.xml.rpc.spi.runtime.ServletSecondDelegate; 32 33 import com.sun.enterprise.webservice.monitoring.WebServiceEngineImpl; 34 import com.sun.enterprise.webservice.monitoring.HttpResponseInfoImpl; 35 import com.sun.enterprise.webservice.monitoring.ThreadLocalInfo; 36 import com.sun.enterprise.webservice.monitoring.EndpointImpl; 37 import com.sun.enterprise.webservice.monitoring.WebServiceTesterServlet; 38 import com.sun.enterprise.webservice.monitoring.Endpoint; 39 import com.sun.enterprise.webservice.monitoring.EndpointType; 40 41 import org.apache.catalina.Loader; 43 44 48 public class JAXRPCServlet extends HttpServlet { 49 50 private ServletDelegate delegate_; 51 private ServletWebServiceDelegate myDelegate_=null; 52 53 public void init(ServletConfig servletConfig) throws ServletException { 54 try { 55 super.init(servletConfig); 56 JaxRpcObjectFactory rpcFactory = JaxRpcObjectFactory.newInstance(); 57 delegate_ = 58 (ServletDelegate) rpcFactory.createServletDelegate(); 59 myDelegate_ = new ServletWebServiceDelegate(delegate_); 60 delegate_.setSecondDelegate(myDelegate_); 61 delegate_.init(servletConfig); 62 63 } catch (ServletException e) { 64 throw e; 65 } catch (Throwable e) { 66 throw new ServletException(e); 67 } 68 } 69 70 public void destroy() { 71 if (delegate_ != null) { 72 delegate_.destroy(); 73 } 74 if (myDelegate_ != null) { 75 myDelegate_.destroy(); 76 } 77 } 78 79 protected void doPost(HttpServletRequest request, 80 HttpServletResponse response) 81 throws ServletException { 82 83 WebServiceEngineImpl wsEngine_ = WebServiceEngineImpl.getInstance(); 84 85 if ("Tester".equalsIgnoreCase(request.getQueryString())) { 86 Endpoint endpt = wsEngine_.getEndpoint(request.getRequestURL().toString()); 87 if (endpt!=null && Boolean.parseBoolean(endpt.getDescriptor().getDebugging())) { 88 WebServiceTesterServlet.invoke(request, response, 89 endpt.getDescriptor()); 90 return; 91 } 92 } 93 94 if (delegate_ != null) { 95 String messageId=null; 97 if (wsEngine_.getGlobalMessageListener()!=null) { 98 Endpoint endpt = wsEngine_.getEndpoint(request.getRequestURL().toString()); 99 messageId = wsEngine_.preProcessRequest(endpt); 100 if (messageId!=null) { 101 ThreadLocalInfo config = new ThreadLocalInfo(messageId, request); 102 wsEngine_.getThreadLocal().set(config); 103 } 104 } 105 106 delegate_.doPost(request, response); 107 108 if (messageId!=null) { 109 HttpResponseInfoImpl info = new HttpResponseInfoImpl(response); 110 wsEngine_.postProcessResponse(messageId, info); 111 } 112 } 113 } 114 115 protected void doGet(HttpServletRequest request, 116 HttpServletResponse response) 117 throws ServletException { 118 119 if ("Tester".equalsIgnoreCase(request.getQueryString())) { 121 122 Endpoint endpt = WebServiceEngineImpl.getInstance().getEndpoint(request.getRequestURL().toString()); 123 if (endpt!=null && Boolean.parseBoolean(endpt.getDescriptor().getDebugging())) { 124 Loader loader = (Loader) endpt.getDescriptor().getBundleDescriptor().getExtraAttribute("WEBLOADER"); 125 if (loader != null) { 126 endpt.getDescriptor().getBundleDescriptor().setClassLoader(loader.getClassLoader()); 127 endpt.getDescriptor().getBundleDescriptor().removeExtraAttribute("WEBLOADER"); 128 } 129 WebServiceTesterServlet.invoke(request, response, 130 endpt.getDescriptor()); 131 return; 132 } 133 } 134 if (delegate_ != null) { 135 delegate_.doGet(request, response); 136 } 137 } 138 139 } 140 | Popular Tags |