001: // You can redistribute this software and/or modify it under the terms of
002: // the Ozone Core License version 1 published by ozone-db.org.
003: //
004: // The original code and portions created by SMB are
005: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
006: //
007: // $Id: DbInvoke.java,v 1.2 2002/06/08 00:49:38 mediumnet Exp $
008:
009: package org.ozoneDB.core.DbRemote;
010:
011: import java.io.*;
012: import org.ozoneDB.DxLib.*;
013: import org.ozoneDB.*;
014: import org.ozoneDB.core.*;
015:
016: /**
017: * @author <a href="http://www.softwarebuero.de/">SMB</a>
018: * @version $Revision: 1.2 $Date: 2002/06/08 00:49:38 $
019: */
020: public final class DbInvoke extends DbCommand implements Externalizable {
021:
022: private OzoneProxy obj;
023:
024: private int methodIndex = -1;
025:
026: private String methodName;
027:
028: private String sig;
029:
030: private Object[] args;
031:
032: private int lockLevel;
033:
034: public DbInvoke() {
035: }
036:
037: public DbInvoke(OzoneProxy _obj, int _methodIndex, Object[] _args,
038: int _lockLevel) {
039: obj = _obj;
040: methodIndex = _methodIndex;
041: args = _args;
042: lockLevel = _lockLevel;
043: }
044:
045: public DbInvoke(OzoneProxy _obj, String method, String _sig,
046: Object[] _args, int _lockLevel) {
047: obj = _obj;
048: methodName = method;
049: sig = _sig;
050: args = _args;
051: lockLevel = _lockLevel;
052: }
053:
054: public void perform(Transaction ta) throws Exception {
055: env.logWriter.newEntry(this , "DbInvoke.perform(): start.",
056: env.logWriter.DEBUG);
057: // result = env.database.invoke (obj, methodName, sig, args, update);
058:
059: try {
060: if (methodIndex > -1) {
061: result = ta.invokeObject(obj.remoteID(), methodIndex,
062: args, lockLevel);
063: } else {
064: result = ta.invokeObject(obj.remoteID(), methodName,
065: sig, args, lockLevel);
066: }
067:
068: result = ResultConverter.substituteOzoneCompatibles(result,
069: getProxyObjectGate());
070: } finally {
071: env.logWriter.newEntry(this , "DbInvoke.perform(): end.",
072: env.logWriter.DEBUG);
073: }
074: }
075:
076: public void writeExternal(ObjectOutput out) throws IOException {
077: out.writeObject(obj);
078: out.writeInt(methodIndex);
079: if (methodIndex == -1) {
080: out.writeObject(methodName);
081: out.writeObject(sig);
082: }
083: out.writeObject(args);
084: out.writeInt(lockLevel);
085: }
086:
087: public void readExternal(ObjectInput in) throws IOException,
088: ClassNotFoundException {
089: obj = (OzoneProxy) in.readObject();
090: methodIndex = in.readInt();
091: if (methodIndex == -1) {
092: methodName = (String) in.readObject();
093: sig = (String) in.readObject();
094: }
095: args = (Object[]) in.readObject();
096: lockLevel = in.readInt();
097: }
098:
099: public String toString() {
100: if (methodIndex > -1) {
101: return "[" + "DbInvoke: " + methodIndex + "]";
102: } else {
103: return "[" + "DbInvoke: " + methodName + "]";
104: }
105: }
106: }
|