1 55 56 package org.jboss.axis.providers.java; 57 58 import org.jboss.axis.AxisFault; 59 import org.jboss.axis.MessageContext; 60 import org.jboss.axis.description.OperationDesc; 61 import org.jboss.axis.message.SOAPEnvelopeAxisImpl; 62 import org.jboss.axis.utils.Messages; 63 import org.jboss.logging.Logger; 64 65 import java.lang.reflect.InvocationTargetException ; 66 import java.lang.reflect.Method ; 67 68 74 public class RPCProvider extends JavaProvider 75 { 76 77 private static Logger log = Logger.getLogger(RPCProvider.class.getName()); 78 79 82 public final static String RPC_INVOCATION = "axis.provider.java.rpc-invocation"; 83 84 93 public void processMessage(MessageContext msgContext, SOAPEnvelopeAxisImpl reqEnv, SOAPEnvelopeAxisImpl resEnv, Object obj) 94 throws Exception 95 { 96 97 if (log.isDebugEnabled()) 98 { 99 log.debug("Enter: RPCProvider.processMessage()"); 100 } 101 102 RPCInvocation invocation = createRPCInvocation(msgContext, reqEnv, resEnv, obj); 103 invocation.prepareFromRequestEnvelope(); 104 105 OperationDesc operation = invocation.getOperation(); 106 Object [] argValues = invocation.getArgValues(); 107 108 msgContext.setProperty(RPC_INVOCATION, invocation); 111 112 reqEnv.setProcessingRPCInvocation(true); 116 resEnv.setProcessingRPCInvocation(true); 117 118 try 120 { 121 Object resObj = invokeTarget(invocation); 122 invocation.prepareResponseEnvelope(resObj); 123 } 124 catch (IllegalArgumentException e) 125 { 126 String methodSig = operation.toString(); 127 String argClasses = ""; 128 for (int i = 0; i < argValues.length; i++) 129 { 130 if (argValues[i] == null) 131 { 132 argClasses += "null"; 133 } 134 else 135 { 136 argClasses += argValues[i].getClass().getName(); 137 } 138 if (i + 1 < argValues.length) 139 { 140 argClasses += ","; 141 } 142 } 143 log.info(Messages.getMessage("dispatchIAE00", new String []{methodSig, argClasses}), e); 144 throw new AxisFault(Messages.getMessage("dispatchIAE00", new String []{methodSig, argClasses}), e); 145 } 146 finally 147 { 148 reqEnv.setProcessingRPCInvocation(false); 149 resEnv.setProcessingRPCInvocation(false); 150 } 151 } 152 153 public RPCInvocation createRPCInvocation(MessageContext msgContext, SOAPEnvelopeAxisImpl reqEnv, SOAPEnvelopeAxisImpl resEnv, Object obj) 154 { 155 RPCInvocation invocation = new RPCInvocation(this, msgContext, reqEnv, resEnv, obj); 156 return invocation; 157 } 158 159 166 protected Object invokeTarget(RPCInvocation invocation) throws Exception 167 { 168 169 MessageContext msgContext = invocation.getMessageContext(); 170 Object targetObject = invocation.getTargetObject(); 171 Method method = invocation.getOperation().getMethod(); 172 Object [] argValues = invocation.getArgValues(); 173 174 try 175 { 176 Object objRes = invokeMethod(msgContext, method, targetObject, argValues); 177 return objRes; 178 } 179 catch (InvocationTargetException e) 180 { 181 if (e.getTargetException() instanceof Exception ) 182 throw (Exception )e.getTargetException(); 183 else 184 throw e; 185 } 186 finally 187 { 188 msgContext.setPastPivot(true); 189 } 190 } 191 192 200 protected Object invokeMethod(MessageContext msgContext, Method method, Object obj, Object [] argValues) 201 throws Exception 202 { 203 204 return (method.invoke(obj, argValues)); 205 } 206 207 214 protected void checkMethodName(MessageContext msgContext, String allowedMethods, String methodName) 215 throws Exception 216 { 217 218 } 220 } 221 | Popular Tags |