1 package org.myoodb.core.command; 25 26 import java.io.*; 27 28 import org.myoodb.*; 29 import org.myoodb.core.*; 30 31 public final class InvokeMethodCommand extends AbstractCommand implements Externalizable 32 { 33 private String m_sig; 34 private Object m_args; 35 private MyOodbProxy m_object; 36 private String m_methodName; 37 private int m_methodIndex; 38 private int m_accessLevel; 39 private Object m_tunnelIdentifier; 40 41 public InvokeMethodCommand() 42 { 43 } 44 45 public InvokeMethodCommand(MyOodbProxy object, int methodIndex, Object [] args, int accessLevel) 46 { 47 m_args = args; 48 m_object = object; 49 m_methodIndex = methodIndex; 50 m_accessLevel = accessLevel; 51 } 52 53 public InvokeMethodCommand(MyOodbProxy object, String methodName, String sig, Object [] args, int accessLevel) 54 { 55 m_sig = sig; 56 m_args = args; 57 m_object = object; 58 m_methodIndex = -1; 59 m_methodName = methodName; 60 m_accessLevel = accessLevel; 61 } 62 63 public void setArguments(Object [] args) 64 { 65 m_args = args; 66 } 67 68 public Object [] getArguments() 69 { 70 return (m_args instanceof Object []) ? (Object []) m_args : null; 71 } 72 73 public void setTunnelPassThroughFlag(boolean flag) 74 { 75 m_args = new Boolean (flag); 76 } 77 78 public boolean getTunnelPassThroughFlag() 79 { 80 return (m_args instanceof Boolean ) ? (Boolean ) m_args : false; 81 } 82 83 public void setTunnelIdentifier(Object identifier) 84 { 85 m_tunnelIdentifier = identifier; 86 } 87 88 public Object getTunnelIdentifier() 89 { 90 return m_tunnelIdentifier; 91 } 92 93 public void process(AbstractTransaction tx) throws Exception 94 { 95 if (m_methodIndex > -1) 96 { 97 m_result = tx.invokeMethod(m_object.getDatabaseHandle(), m_methodIndex, (Object []) m_args, m_accessLevel); 98 } 99 else 100 { 101 m_result = tx.invokeMethod(m_object.getDatabaseHandle(), m_methodName, m_sig, (Object []) m_args, m_accessLevel); 102 } 103 104 m_result = Converter.LocalToProxy(m_result); 105 } 106 107 public void writeExternal(ObjectOutput out) throws IOException 108 { 109 out.writeObject(m_object); 110 out.writeInt(m_methodIndex); 111 if (m_methodIndex == -1) 112 { 113 out.writeObject(m_methodName); 114 out.writeObject(m_sig); 115 } 116 117 out.writeInt(m_accessLevel); 118 out.writeObject(m_args); 119 out.writeObject(m_tunnelIdentifier); 120 } 121 122 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException 123 { 124 m_object = (MyOodbProxy) in.readObject(); 125 m_methodIndex = in.readInt(); 126 if (m_methodIndex == -1) 127 { 128 m_methodName = (String ) in.readObject(); 129 m_sig = (String ) in.readObject(); 130 } 131 132 m_accessLevel = in.readInt(); 133 m_args = in.readObject(); 134 m_tunnelIdentifier = in.readObject(); 135 } 136 } 137 | Popular Tags |