1 7 8 package org.jboss.webservice.server; 10 11 13 import org.jboss.axis.MessageContext; 14 import org.jboss.axis.providers.java.RPCInvocation; 15 import org.jboss.axis.providers.java.RPCProvider; 16 import org.jboss.logging.Logger; 17 import org.jboss.metadata.WebMetaData; 18 import org.jboss.webservice.Constants; 19 20 import java.lang.reflect.Method ; 21 import java.util.HashMap ; 22 import java.util.Map ; 23 24 30 public class InvokerProviderJSE extends InvokerProvider 31 { 32 33 static final long serialVersionUID = 17292705231485822L; 34 private Logger log = Logger.getLogger(InvokerProviderJSE.class); 36 37 private Map methodMap = new HashMap (); 39 40 43 protected Object makeNewServiceObject(MessageContext msgContext, String className) throws Exception 44 { 45 log.debug("makeNewServiceObject: class=" + className); 46 47 String serviceEndpointBean = portComponentInfo.getPortComponentMetaData().getServiceEndpointBean(); 48 if (serviceEndpointBean == null) 49 throw new ServiceException("Service endpoint bean class not set"); 50 51 ClassLoader ctxLoader = getContextClassLoader(); 53 msgContext.setClassLoader(ctxLoader); 54 55 Object obj = super.makeNewServiceObject(msgContext, serviceEndpointBean); 56 return obj; 57 } 58 59 67 protected Object invokeTarget(RPCInvocation invocation) throws Exception 68 { 69 MessageContext msgContext = invocation.getMessageContext(); 70 71 try 72 { 73 if (handlerChain.handleRequest(msgContext) == false) 75 { 76 log.warn("FIXME: handlerChain.handleRequest() returned false"); 77 return null; 78 } 79 80 invocation = (RPCInvocation)msgContext.getProperty(RPCProvider.RPC_INVOCATION); 82 } 83 catch (Exception e) 84 { 85 log.error("Error processing request handler chain", e); 86 throw e; 87 } 88 89 Object retObj = null; 90 try 91 { 92 retObj = super.invokeTarget(invocation); 94 } 95 catch (Exception e) 96 { 97 msgContext.setProperty(Constants.LAST_FAULT, e); 98 log.error("Error from service endpoint, processing fault handler chain", e); 99 100 if (handlerChain.handleFault(msgContext) == false) 102 { 103 log.warn("FIXME: handlerChain.handleFault() returned false"); 104 return null; 105 } 106 107 throw e; 109 } 110 111 try 112 { 113 invocation.prepareResponseEnvelope(retObj); 115 116 if (handlerChain.handleResponse(msgContext) == false) 118 { 119 log.warn("FIXME: handlerChain.handleResponse() returned false"); 120 return null; 121 } 122 } 123 catch (Exception e) 124 { 125 log.error("Error processing response handler chain", e); 126 throw e; 127 } 128 129 return retObj; 130 } 131 132 140 protected Object invokeServiceEndpoint(MessageContext msgContext, Method method, Object obj, Object [] argValues) 141 throws Exception 142 { 143 log.debug("Invoke JSE: " + method); 144 145 Method beanMethod = (Method )methodMap.get(method); 147 if (beanMethod == null) 148 { 149 beanMethod = obj.getClass().getMethod(method.getName(), method.getParameterTypes()); 150 methodMap.put(method, beanMethod); 151 } 152 153 Object retObj = beanMethod.invoke(obj, argValues); 155 return retObj; 156 } 157 158 161 protected ClassLoader getContextClassLoader() 162 { 163 WebMetaData metaData = (WebMetaData)portComponentInfo.getDeploymentInfo().metaData; 164 return metaData.getContextLoader(); 165 } 166 } 167 | Popular Tags |