RMI原理揭秘之远程方法调用
来源:互联网 发布:怀化干部在线网络 编辑:程序博客网 时间:2024/06/07 18:39
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
public
void
bind(java.lang.String $param_String_1, java.rmi.Remote $param_Remote_2)
throws
java.rmi.AccessException, java.rmi.AlreadyBoundException, java.rmi.RemoteException
{
try
{
if
(useNewInvoke) {
ref.invoke(
this
, $method_bind_0,
new
java.lang.Object[] {$param_String_1, $param_Remote_2}, 7583982177005850366L);
}
else
{
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject)
this
, operations,
0
, interfaceHash);
try
{
java.io.ObjectOutput out = call.getOutputStream();
out.writeObject($param_String_1);
out.writeObject($param_Remote_2);
}
catch
(java.io.IOException e) {
throw
new
java.rmi.MarshalException(
"error marshalling arguments"
, e);
}
ref.invoke(call);
ref.done(call);
}
}
catch
(java.lang.RuntimeException e) {
throw
e;
}
catch
(java.rmi.RemoteException e) {
throw
e;
}
catch
(java.rmi.AlreadyBoundException e) {
throw
e;
}
catch
(java.lang.Exception e) {
throw
new
java.rmi.UnexpectedException(
"undeclared checked exception"
, e);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public
StreamRemoteCall(Connection c, ObjID id,
int
op,
long
hash)
throws
RemoteException
{
try
{
conn = c;
Transport.transportLog.log(Log.VERBOSE,
"write remote call header..."
);
// write out remote call header info...
// call header, part 1 (read by Transport)
conn.getOutputStream().write(TransportConstants.Call);
getOutputStream();
// creates a MarshalOutputStream
id.write(out);
// object id (target of call)
// call header, part 2 (read by Dispatcher)
out.writeInt(op);
// method number (operation index)
out.writeLong(hash);
// stub/skeleton hash
}
catch
(IOException e) {
throw
new
MarshalException(
"Error marshaling call header"
, e);
}
}
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
public
boolean
serviceCall(
final
RemoteCall call) {
try
{
final
Remote impl;
ObjID id;
try
{
id = ObjID.read(call.getInputStream());
}
catch
(java.io.IOException e) {
throw
new
MarshalException(
"unable to read objID"
, e);
}
/* get the remote object */
Transport transport = id.equals(dgcID) ? null : this;
Target target =
ObjectTable.getTarget(new ObjectEndpoint(id, transport));
if (target == null || (impl = target.getImpl()) == null) {
throw new NoSuchObjectException("no such object in table");
}
final Dispatcher disp = target.getDispatcher();
target.incrementCallCount();
try {
/* call the dispatcher */
transportLog.log(Log.VERBOSE, "call dispatcher");
final AccessControlContext acc =
target.getAccessControlContext();
ClassLoader ccl = target.getContextClassLoader();
Thread t = Thread.currentThread();
ClassLoader savedCcl = t.getContextClassLoader();
try {
t.setContextClassLoader(ccl);
currentTransport.set(this);
try {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedExceptionAction<Void>() {
public Void run() throws IOException {
checkAcceptPermission(acc);
disp.dispatch(impl, call);
return null;
}
}, acc);
} catch (java.security.PrivilegedActionException pae) {
throw (IOException) pae.getException();
}
} finally {
t.setContextClassLoader(savedCcl);
currentTransport.set(null);
}
} catch (IOException ex) {
transportLog.log(Log.BRIEF,
"exception thrown by dispatcher: ", ex);
return false;
} finally {
target.decrementCallCount();
}
} catch (RemoteException e) {
// if calls are being logged, write out exception
if (UnicastServerRef.callLog.isLoggable(Log.BRIEF)) {
// include client host name if possible
String clientHost = "";
try {
clientHost = "[" +
RemoteServer.getClientHost() + "] ";
} catch (ServerNotActiveException ex) {
}
String message = clientHost + "exception: ";
UnicastServerRef.callLog.log(Log.BRIEF, message, e);
}
/* We will get a RemoteException if either a) the objID is
* not readable, b) the target is not in the object table, or
* c) the object is in the midst of being unexported (note:
* NoSuchObjectException is thrown by the incrementCallCount
* method if the object is being unexported). Here it is
* relatively safe to marshal an exception to the client
* since the client will not have seen a return value yet.
*/
try
{
ObjectOutput out = call.getResultStream(
false
);
UnicastServerRef.clearStackTraces(e);
out.writeObject(e);
call.releaseOutputStream();
}
catch
(IOException ie) {
transportLog.log(Log.BRIEF,
"exception thrown marshalling exception: "
, ie);
return
false
;
}
}
return
true
;
}
1
id = ObjID.read(call.getInputStream());
1
2
3
Target target =
ObjectTable.getTarget(
new
ObjectEndpoint(id, transport));
impl = target.getImpl()
1
disp.dispatch(impl, call);
0 0
- RMI原理揭秘之远程方法调用
- RMI原理揭秘之远程对象
- RMI原理揭秘之远程对象
- RMI原理揭秘之远程对象
- RMI原理揭秘之远程对象
- Java之RMI(远程方法调用)
- javaEE之远程方法调用(RMI)
- RMI,远程方法调用
- RMI远程方法调用
- rmi 远程方法调用
- RMI远程方法调用
- RMI远程方法调用
- RMI 远程方法调用
- rmi远程方法调用
- RMI 远程方法调用
- RMI远程方法调用
- RMI远程方法调用
- Java RMI 框架原理(远程方法调用)
- linux-ubuntu使用shadowsocks客户端配置
- 论文笔记 | Rethinking the Inception Architecture for Computer Vision
- Swift里的值类型与引用类型
- 何为CFTA?与FTA有什么关系?CFTA包含哪些测试项目?
- 【C/C++】异常机制
- RMI原理揭秘之远程方法调用
- mysql 与elasticsearch实时同步常用插件及优缺点对比
- 访问控制和protected
- 深入理解Java的接口和抽象类
- Swift 可选类型完美解决占位问题
- aapt.exe'' finished with non-zero exit value -1073741819
- 传统电路交换网和软交换
- iOS学习- 24 Core Data by Tutorials - CH04
- JAVA程序:字符串数组交集、并集和差集