00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package org.objectweb.proactive.core.body.http.util.messages;
00032
00033 import java.io.Serializable;
00034 import java.lang.reflect.InvocationTargetException;
00035 import java.lang.reflect.Method;
00036 import java.util.ArrayList;
00037 import java.util.HashMap;
00038
00039 import org.objectweb.proactive.Body;
00040 import org.objectweb.proactive.core.UniqueID;
00041 import org.objectweb.proactive.core.body.http.util.HttpUtils;
00042 import org.objectweb.proactive.ext.security.exceptions.SecurityNotAvailableException;
00043
00044
00050 public class BodyRequest extends ReflectRequest implements Serializable {
00051 private static HashMap hMapMethods;
00052
00053 static {
00054 hMapMethods = getHashMapReflect(Body.class);
00055 }
00056
00057 private String methodName;
00058 private ArrayList parameters = new ArrayList();
00059 private UniqueID oaid;
00060 private Body body = null;
00061
00068 public BodyRequest(String methodName, ArrayList parameters, UniqueID oaid,
00069 String url) {
00070 super(url);
00071 this.methodName = methodName;
00072 this.parameters = parameters;
00073 this.oaid = oaid;
00074 }
00075
00076 public String getMethodName() {
00077 return this.methodName;
00078 }
00079
00080 public Object getReturnedObject() throws Exception {
00081 if (this.returnedObject instanceof Exception) {
00082
00083 throw (Exception) this.returnedObject;
00084 }
00085 return this.returnedObject;
00086 }
00087
00095 public Object processMessage() throws Exception {
00096 Object result = null;
00097
00098 if (body == null) {
00099 this.body = HttpUtils.getBody(this.oaid);
00100 }
00101
00102
00103 Method m = getProActiveRuntimeMethod(methodName, parameters,
00104 hMapMethods.get(methodName));
00105
00106 try {
00107 result = m.invoke(body, parameters.toArray());
00108 } catch (IllegalArgumentException e) {
00109
00110 throw e;
00111 } catch (IllegalAccessException e) {
00112
00113 throw e;
00114 } catch (InvocationTargetException e) {
00115
00116
00117 throw new SecurityNotAvailableException(e.getCause());
00118 } catch (Exception e) {
00119
00120
00121 throw e;
00122 }
00123
00124 return result;
00125 }
00126 }