1 53 package org.bsf.remoting.http; 54 55 import org.bsf.remoting.EJBDefinition; 56 import org.bsf.remoting.http.HttpServiceKey; 57 58 import java.io.Serializable ; 59 60 61 67 public class HttpServiceRequest implements Serializable { 68 69 private EJBDefinition remoteService; 70 private String methodName; 71 private String [] paramTypesName; 72 private Object [] args; 73 private HttpServiceKey keyToStatefullService; 74 75 82 public HttpServiceRequest(EJBDefinition remoteService, String methodToCall, 83 Class [] paramTypes, Object [] args) { 84 this.remoteService = remoteService; 85 this.methodName = methodToCall; 86 setParamTypes(paramTypes); 87 this.args = args; 88 } 89 90 97 public HttpServiceRequest(HttpServiceKey keyToStatefullService, String methodToCall, 98 Class [] paramTypes, Object [] args) { 99 this.keyToStatefullService = keyToStatefullService; 100 this.methodName = methodToCall; 101 setParamTypes(paramTypes); 102 this.args = args; 103 } 104 105 public boolean isStatefull() { 106 if (keyToStatefullService != null) return true; 107 return false; 108 } 109 110 public boolean isStateless() { 111 if (isStatefull()) return false; 112 return true; 113 } 114 115 public EJBDefinition getRemoteService() { 116 return remoteService; 117 } 118 119 public void setRemoteService(EJBDefinition remoteService) { 120 this.remoteService = remoteService; 121 } 122 123 public String getMethodName() { 124 return methodName; 125 } 126 127 public void setMethodName(String methodName) { 128 this.methodName = methodName; 129 } 130 131 134 public Class [] getParamTypes() { 135 ClassLoader curClassLoader = this.getClass().getClassLoader(); 136 Class [] result = new Class [paramTypesName.length]; 137 for (int i = 0; i < paramTypesName.length; i++) { 138 String type = paramTypesName[i]; 139 Class arg = null; 140 if (type == null) 141 arg = null; 142 else if (type.equals("int")) 143 arg = Integer.TYPE; 144 else if (type.equals("boolean")) 145 arg = Boolean.TYPE; 146 else if (type.equals("float")) 147 arg = Float.TYPE; 148 else if (type.equals("byte")) 149 arg = Byte.TYPE; 150 else if (type.equals("short")) 151 arg = Short.TYPE; 152 else if (type.equals("char")) 153 arg = Character.TYPE; 154 else if (type.equals("long")) 155 arg = Long.TYPE; 156 else if (type.equals("double")) 157 arg = Double.TYPE; 158 else 159 try { 160 arg = Class.forName(type); 161 } catch (ClassNotFoundException e) { 162 throw new RuntimeException (e.getLocalizedMessage()); 163 } 164 result[i] = arg; 165 } 166 return result; 167 } 168 169 public void setParamTypes(Class [] paramTypes) { 170 paramTypesName = new String [paramTypes.length]; 171 for (int i = 0; i < paramTypes.length; i++) { 172 Class type = paramTypes[i]; 173 paramTypesName[i] = type.getName(); 174 } 175 } 176 177 public Object [] getArgs() { 178 return args; 179 } 180 181 public void setArgs(Object [] args) { 182 this.args = args; 183 } 184 185 public HttpServiceKey getKeyToStatefullService() { 186 return keyToStatefullService; 187 } 188 189 public void setKeyToStatefullService(HttpServiceKey keyToStatefullService) { 190 this.keyToStatefullService = keyToStatefullService; 191 } 192 } | Popular Tags |