1 10 11 package com.sun.enterprise.jbi.serviceengine.bridge; 12 13 import com.sun.enterprise.jbi.serviceengine.ServiceEngineException; 14 import com.sun.enterprise.jbi.serviceengine.core.ServiceEngineEndpoint; 15 import com.sun.enterprise.webservice.EjbRuntimeEndpointInfo; 16 import com.sun.enterprise.webservice.JAXWSRuntimeEpiRegistry; 17 import com.sun.enterprise.webservice.WebServiceEjbEndpointRegistry; 18 import com.sun.xml.ws.spi.runtime.RuntimeEndpointInfo; 19 import com.sun.xml.ws.spi.runtime.WSRtObjectFactory; 20 import com.sun.xml.ws.spi.runtime.WebServiceContext; 21 import javax.xml.ws.handler.MessageContext.Scope; 22 23 27 public class JAXWSRuntimeEndpointHelper { 28 29 30 public JAXWSRuntimeEndpointHelper() { 31 } 32 33 public static void releaseEjbEndpoint(ServiceEngineEndpoint endpt) { 34 WebServiceEjbEndpointRegistry registry = 35 WebServiceEjbEndpointRegistry.getRegistry(); 36 EjbRuntimeEndpointInfo ejbRtEndptInfo = 37 registry.getEjbWebServiceEndpoint(endpt.getURI(), "POST", null); 38 ejbRtEndptInfo.releaseImplementor(); 39 } 40 41 public static Object populateRuntimeInfo(ServiceEngineEndpoint endpt) 42 throws ServiceEngineException { 43 RuntimeEndpointInfo runtimeInfo = null; 44 if(endpt.isImplementedByEJB()) { 45 runtimeInfo = populateEjbRuntimeInfo(endpt); 46 } else { 47 runtimeInfo = populateWebRuntimeInfo(endpt); 48 } 49 setMessageContext(runtimeInfo); 50 return runtimeInfo; 51 } 52 53 static void setMessageContext(RuntimeEndpointInfo runtimeInfo) { 54 if(runtimeInfo != null) { 55 WebServiceContext wsCtxt = runtimeInfo.getWebServiceContext(); 57 javax.xml.ws.handler.MessageContext msgCtxt = 58 (javax.xml.ws.handler.MessageContext )WSRtObjectFactory.newInstance().createMessageContext(); 59 msgCtxt.put(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY,Boolean.FALSE); 60 msgCtxt.setScope(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY, Scope.APPLICATION); 61 wsCtxt.setMessageContext(msgCtxt); 62 } 63 } 64 65 private static RuntimeEndpointInfo populateEjbRuntimeInfo( 66 ServiceEngineEndpoint endpt) throws ServiceEngineException { 67 try { 68 WebServiceEjbEndpointRegistry registry = 69 WebServiceEjbEndpointRegistry.getRegistry(); 70 71 EjbRuntimeEndpointInfo ejbRtEndptInfo = 72 registry.getEjbWebServiceEndpoint(endpt.getURI(), "POST", null); 73 74 RuntimeEndpointInfo rtEndptInfo = ejbRtEndptInfo.prepareInvocation(true); 75 return rtEndptInfo; 76 } catch(Exception e) { 77 throw new ServiceEngineException(e.getMessage()); 78 } 79 } 80 81 private static RuntimeEndpointInfo populateWebRuntimeInfo( 82 ServiceEngineEndpoint endpt) throws ServiceEngineException { 83 try { 84 String url = endpt.getURI(); 85 String contextRoot = endpt.getContextRoot(); 86 87 RuntimeEndpointInfo endpointInfo = 88 JAXWSRuntimeEpiRegistry.getInstance(). 89 getRuntimeEndpointInfo(contextRoot, url, url); 90 ClassLoader prevClassLoader = Thread.currentThread().getContextClassLoader(); 91 Thread.currentThread().setContextClassLoader(endpt.getClassLoader()); 92 endpointInfo.init(); 93 94 Thread.currentThread().setContextClassLoader(prevClassLoader); 95 return endpointInfo; 96 } catch(Exception e) { 97 throw new ServiceEngineException(e); 98 } 99 } 100 } 101 | Popular Tags |