1 29 30 package com.caucho.iiop; 31 32 import com.caucho.log.Log; 33 34 import java.lang.reflect.InvocationTargetException ; 35 import java.lang.reflect.Method ; 36 import java.util.logging.Logger ; 37 38 public class SkeletonMethod { 39 private static final Logger log = Log.open(SkeletonMethod.class); 40 41 private IiopSkeleton _skeleton; 42 private Method _method; 43 44 private MarshallObject []_marshallArgs; 45 private MarshallObject _marshallReturn; 46 47 SkeletonMethod(IiopSkeleton skeleton, Method method, boolean isJava) 48 { 49 _skeleton = skeleton; 50 _method = method; 51 52 54 Class []paramTypes = method.getParameterTypes(); 55 56 _marshallArgs = new MarshallObject[paramTypes.length]; 57 58 for (int i = 0; i < _marshallArgs.length; i++) 59 _marshallArgs[i] = MarshallObject.create(paramTypes[i], isJava); 60 61 _marshallReturn = MarshallObject.create(method.getReturnType(), isJava); 62 } 63 64 void service(Object object, IiopReader reader, IiopWriter writer) 65 throws Throwable 66 { 67 Object []args = new Object [_marshallArgs.length]; 68 69 for (int i = 0; i < args.length; i++) { 70 args[i] = _marshallArgs[i].unmarshall(reader); 71 } 72 73 try { 74 Object result = _method.invoke(object, args); 75 76 writer.startReplyOk(reader.getRequestId()); 77 78 _marshallReturn.marshall(result, writer); 79 } catch (InvocationTargetException e) { 80 throw e.getCause(); 81 } 82 } 83 } 84 | Popular Tags |