KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > core > DbRemote > DbInvoke


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Core License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: DbInvoke.java,v 1.5 2002/09/18 06:54:15 per_nyfelt Exp $
8

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 /**
19  * @author <a HREF="http://www.softwarebuero.de/">SMB</a>
20  * @version $Revision: 1.5 $Date: 2002/09/18 06:54:15 $
21  */

22 public final class DbInvoke extends DbCommand implements Externalizable {
23
24     private OzoneProxy obj;
25
26     private int methodIndex = -1;
27
28     private String JavaDoc methodName;
29
30     private String JavaDoc sig;
31
32     private Object JavaDoc[] args;
33
34     private int lockLevel;
35
36
37     public DbInvoke() {
38     }
39
40
41     public DbInvoke( OzoneProxy _obj, int _methodIndex, Object JavaDoc[] _args, int _lockLevel ) {
42         obj = _obj;
43         methodIndex = _methodIndex;
44         args = _args;
45         lockLevel = _lockLevel;
46     }
47
48
49     public DbInvoke( OzoneProxy _obj, String JavaDoc method, String JavaDoc _sig, Object JavaDoc[] _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 JavaDoc {
59         env.logWriter.newEntry (this, "DbInvoke.perform(): start.", env.logWriter.DEBUG2);
60         // result = env.database.invoke (obj, methodName, sig, args, update);
61

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 JavaDoc {
89         obj = (OzoneProxy)in.readObject();
90         methodIndex = in.readInt();
91         if (methodIndex == -1) {
92             methodName = (String JavaDoc)in.readObject();
93             sig = (String JavaDoc)in.readObject();
94         }
95         args = (Object JavaDoc[])in.readObject();
96         lockLevel = in.readInt();
97     }
98
99
100     public String JavaDoc toString() {
101         if (methodIndex > -1) {
102             return "[" + "DbInvoke: " + methodIndex + "]";
103         } else {
104             return "[" + "DbInvoke: " + methodName + "]";
105         }
106     }
107 }
108
Popular Tags