-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNEMethodInvocation.java~
106 lines (93 loc) · 3.01 KB
/
NEMethodInvocation.java~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import java.io.*;
import java.net.*;
import java.lang.*;
import java.lang.reflect.*;
public class NEMethodInvocation implements Serializable {
private boolean usingId;
private int methodId;
private String objectType;
private String methodName;
private String[] argTypes;
private Serializable[] args;
private boolean[] remote;
/*
* If the method id is known, create a NEMethodInvocation object with that.
*/
public NEMethodInvocation (int methodId, Serializable[] args, boolean[] remote) {
usingId = true;
this.methodId = methodId;
this.args = new Serializable[args.length];
this.remote = new boolean[args.length];
for (int i = 0; i < args.length; i++) {
this.args[i] = args[i];
this.remote[i] = remote[i];
}
}
/*
* If the method id is not known, create a NEMethodInvocation object
* from the method name and method parameter types.
*/
public NEMethodInvocation (String objectType, String methodName,
String[] argTypes, Serializable[] args, boolean[] remote) {
usingId = false;
this.objectType = objectType;
this.methodName = methodName;
this.argTypes = new String[args.length];
this.args = new Serializable[args.length];
this.remote = new boolean[args.length];
for (int i = 0; i < args.length; i++) {
this.argTypes[i] = argTypes[i];
this.args[i] = args[i];
this.remote[i] = remote[i];
}
}
/*
* If the method id is not known, create a NEMethodInvocation object
* from the method name and method parameter types.
*/
public NEMethodInvocation (Class<?> objectType, String methodName,
Class<?>[] argTypes, Serializable[] args, boolean[] remote) {
usingId = false;
this.objectType = objectType.getName ();
this.methodName = methodName;
this.argTypes = new String[args.length];
this.args = new Serializable[args.length];
this.remote = new boolean[args.length];
for (int i = 0; i < args.length; i++) {
this.argTypes[i] = argTypes[i].getName ();
this.args[i] = args[i];
this.remote[i] = remote[i];
}
}
public int getMethodId () {
return methodId;
}
public boolean isUsingId () {
return usingId;
}
public Class<?> getObjectType () throws ClassNotFoundException {
return Class.forName (objectType);
}
public String getMethodName () {
return methodName;
}
public Class<?>[] getArgumentTypes () throws ClassNotFoundException {
Class<?>[] argTypes = new Class<?>[args.length];
if (! usingId) return null;
for (int i = 0; i < args.length; i++) {
argTypes[i] = Class.forName (this.argTypes[i]);
}
return argTypes;
}
public Object[] getArguments () {
Object[] arguments = new Object[args.length];
for (int i = 0; i < args.length; i++) {
if (remote[i]) {
NERemoteObjectReference objectRef = (NERemoteObjectReference) args[i];
arguments[i] = objectRef.localise ();
}
else arguments[i] = args[i];
}
return arguments;
}
}