1 9 package org.ozoneDB.core.DbRemote; 10 11 import org.ozoneDB.OzoneProxy; 12 import org.ozoneDB.core.ResultConverter; 13 import org.ozoneDB.core.Transaction; 14 15 import java.io.*; 16 17 18 22 public final class DbInvoke extends DbCommand implements Externalizable { 23 24 private OzoneProxy obj; 25 26 private int methodIndex = -1; 27 28 private String methodName; 29 30 private String sig; 31 32 private Object [] args; 33 34 private int lockLevel; 35 36 37 public DbInvoke() { 38 } 39 40 41 public DbInvoke( OzoneProxy _obj, int _methodIndex, Object [] _args, int _lockLevel ) { 42 obj = _obj; 43 methodIndex = _methodIndex; 44 args = _args; 45 lockLevel = _lockLevel; 46 } 47 48 49 public DbInvoke( OzoneProxy _obj, String method, String _sig, Object [] _args, int _lockLevel ) { 50 obj = _obj; 51 methodName = method; 52 sig = _sig; 53 args = _args; 54 lockLevel = _lockLevel; 55 } 56 57 58 public void perform( Transaction ta ) throws Exception { 59 env.logWriter.newEntry (this, "DbInvoke.perform(): start.", env.logWriter.DEBUG2); 60 62 try { 63 if (methodIndex > -1) { 64 result = ta.invokeObject( obj.remoteID(), methodIndex, args, lockLevel ); 65 } else { 66 result = ta.invokeObject( obj.remoteID(), methodName, sig, args, lockLevel ); 67 } 68 69 result = ResultConverter.substituteOzoneCompatibles(result,getProxyObjectGate()); 70 } finally { 71 env.logWriter.newEntry (this, "DbInvoke.perform(): end.", env.logWriter.DEBUG2); 72 } 73 } 74 75 76 public void writeExternal( ObjectOutput out ) throws IOException { 77 out.writeObject( obj ); 78 out.writeInt( methodIndex ); 79 if (methodIndex == -1) { 80 out.writeObject( methodName ); 81 out.writeObject( sig ); 82 } 83 out.writeObject( args ); 84 out.writeInt( lockLevel ); 85 } 86 87 88 public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { 89 obj = (OzoneProxy)in.readObject(); 90 methodIndex = in.readInt(); 91 if (methodIndex == -1) { 92 methodName = (String )in.readObject(); 93 sig = (String )in.readObject(); 94 } 95 args = (Object [])in.readObject(); 96 lockLevel = in.readInt(); 97 } 98 99 100 public String toString() { 101 if (methodIndex > -1) { 102 return "[" + "DbInvoke: " + methodIndex + "]"; 103 } else { 104 return "[" + "DbInvoke: " + methodName + "]"; 105 } 106 } 107 } 108 | Popular Tags |