1 6 7 package org.jfox.ioc.connector; 8 9 import java.io.IOException ; 10 import java.lang.reflect.Method ; 11 import java.rmi.MarshalledObject ; 12 13 import org.jfox.ioc.util.Marshaller; 14 15 18 19 public abstract class AbstractInvocation implements Invocation { 20 private ObjectId objectId = null; 21 22 private String methodHash = null; 23 private Object [] args = null; 24 25 29 private transient Method method = null; 30 31 35 private transient Object targetObject = null; 36 37 private boolean clustable = false; 38 39 public AbstractInvocation(ObjectId objectId, String methodHash, Object [] args) { 40 this.objectId = objectId; 41 this.methodHash = methodHash; 42 this.args = args; 43 } 44 45 public ObjectId getObjectId() { 46 return objectId; 47 } 48 49 public String getMethodHash() { 50 return methodHash; 51 } 52 53 public Object [] getArgs() { 54 return args; 55 } 56 57 public void setMethod(Method method) { 58 this.method = method; 59 } 60 61 public Method getMethod() { 62 return method; 63 } 64 65 public String toString() { 66 StringBuffer sb = new StringBuffer (); 67 sb.append("Invocation {type="); 68 sb.append(this.getClass().getName()); 69 sb.append(",objectId="); 70 sb.append(objectId); 71 if(method != null){ 72 sb.append(", method="); 73 sb.append(method.getName()); 74 } 75 sb.append(", methodHash="); 76 sb.append(methodHash); 77 sb.append("}"); 78 return sb.toString(); 79 } 80 81 public synchronized Object getTargetObject() { 82 if(( targetObject != null) && (targetObject instanceof MarshalledObject )) { 83 targetObject = Marshaller.unmarshall(targetObject); 84 } 85 return targetObject; 86 } 87 88 public void setTargetObject(Object targetObject) { 89 this.targetObject = targetObject; 90 } 91 92 public boolean isClustable() { 93 return clustable; 94 } 95 96 public void setClustable(boolean clustable) { 97 this.clustable = clustable; 98 } 99 100 private void writeObject(java.io.ObjectOutputStream out) 101 throws IOException { 102 out.defaultWriteObject(); 103 out.writeObject(Marshaller.marshall(targetObject)); 104 } 105 106 private void readObject(java.io.ObjectInputStream in) 107 throws IOException , ClassNotFoundException { 108 in.defaultReadObject(); 109 targetObject = in.readObject(); 110 } 111 112 113 public static void main(String [] args) { 114 115 } 116 } 117 | Popular Tags |