Java RMI:由 rmic 编译器生成的存根框架的作用是什么
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16886889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java RMI : What is the role of the stub-skeleton that are generated by the rmic compiler
提问by user2435860
I am currently learning Java RMI (Remote Method Invocation), and I followed the tutorial provided by Oracle on it′s website. I have a particular question however:
我目前正在学习 Java RMI(远程方法调用),我遵循了 Oracle 在其网站上提供的教程。但是,我有一个特别的问题:
What is the use of the stub-skeleton generated by rmic? Do I really need it?
rmic生成的stub-skeleton有什么用?我真的需要吗?
回答by Thomas
The Stub/Skeleton hides the communication details away from the developer. The Stub is the class that implements the remote interface. It serves as a client-side placeholder for the remote object. The stub communicates with the server-side skeleton. The skeleton is the stub's counterpart on server-side. Both communicate via the network. The skeleton actually knows the real remote objects delegates the stub's request to it and returns the response to the stub. You require both as they are the essential building blocks for RMI.
Stub/Skeleton 向开发人员隐藏了通信细节。Stub 是实现远程接口的类。它充当远程对象的客户端占位符。存根与服务器端框架通信。骨架是服务器端存根的对应物。两者都通过网络进行通信。骨架实际上知道真正的远程对象将存根的请求委托给它并将响应返回给存根。您需要两者,因为它们是 RMI 的基本构建块。