1 15 16 package com.jdon.bussinessproxy.remote.http; 17 18 import com.jdon.bussinessproxy.TargetMetaDef; 19 import java.io.Serializable ; 20 21 22 public class HttpRequest implements Serializable { 23 24 private TargetMetaDef targetMetaDef; 25 private String methodName; 26 private String [] paramTypesName; 27 private Object [] args; 28 29 public HttpRequest(TargetMetaDef targetMetaDef, String methodToCall, 30 Class [] paramTypes, Object [] args) { 31 this.targetMetaDef = targetMetaDef; 32 this.methodName = methodToCall; 33 setParamTypes(paramTypes); 34 this.args = args; 35 } 36 37 38 public boolean isStatefull() { 39 return true; 40 } 41 42 43 public TargetMetaDef getTargetMetaDef() { 44 return targetMetaDef; 45 } 46 47 public void setTargetMetaDef(TargetMetaDef targetMetaDef) { 48 this.targetMetaDef = targetMetaDef; 49 } 50 51 public String getMethodName() { 52 return methodName; 53 } 54 55 public void setMethodName(String methodName) { 56 this.methodName = methodName; 57 } 58 59 62 public Class [] getParamTypes() { 63 ClassLoader curClassLoader = this.getClass().getClassLoader(); 64 Class [] result = new Class [paramTypesName.length]; 65 for (int i = 0; i < paramTypesName.length; i++) { 66 String type = paramTypesName[i]; 67 Class arg = null; 68 if (type == null) 69 arg = null; 70 else if (type.equals("int")) 71 arg = Integer.TYPE; 72 else if (type.equals("boolean")) 73 arg = Boolean.TYPE; 74 else if (type.equals("float")) 75 arg = Float.TYPE; 76 else if (type.equals("byte")) 77 arg = Byte.TYPE; 78 else if (type.equals("short")) 79 arg = Short.TYPE; 80 else if (type.equals("char")) 81 arg = Character.TYPE; 82 else if (type.equals("long")) 83 arg = Long.TYPE; 84 else if (type.equals("double")) 85 arg = Double.TYPE; 86 else 87 try { 88 arg = Class.forName(type); 89 } catch (ClassNotFoundException e) { 90 throw new RuntimeException (e.getLocalizedMessage()); 91 } 92 result[i] = arg; 93 } 94 return result; 95 } 96 97 public void setParamTypes(Class [] paramTypes) { 98 paramTypesName = new String [paramTypes.length]; 99 for (int i = 0; i < paramTypes.length; i++) { 100 Class type = paramTypes[i]; 101 paramTypesName[i] = type.getName(); 102 } 103 } 104 105 public Object [] getArgs() { 106 return args; 107 } 108 109 public void setArgs(Object [] args) { 110 this.args = args; 111 } 112 113 } 114 | Popular Tags |