java之RMI

什么是RMI

The Java Remote Method Invocation (RMI) system allows an object running in one Java virtual machine to invoke methods on an object running in another Java virtual machine. RMI provides for remote communication between programs written in the Java programming language.

Note: If you are connecting to an existing IDL program, you should use Java IDL rather than RMI.

JMI 原理

RMI applications often comprise two separate programs, a server and a client. A typical server program creates some remote objects, makes references to these objects accessible, and waits for clients to invoke methods on these objects. A typical client program obtains a remote reference to one or more remote objects on a server and then invokes methods on them. RMI provides the mechanism by which the server and the client communicate and pass information back and forth. Such an application is sometimes referred to as a distributed object application.

Distributed object applications need to do the following:

  • Locate remote objects. Applications can use various mechanisms to obtain references to remote objects. For example, an application can register its remote objects with RMI's simple naming facility, the RMI registry. Alternatively, an application can pass and return remote object references as part of other remote invocations.
  • Communicate with remote objects. Details of communication between remote objects are handled by RMI. To the programmer, remote communication looks similar to regular Java method invocations.
  • Load class definitions for objects that are passed around. Because RMI enables objects to be passed back and forth, it provides mechanisms for loading an object's class definitions as well as for transmitting an object's data.
    The following illustration depicts an RMI distributed application that uses the RMI registry to obtain a reference to a remote object. The server calls the registry to associate (or bind) a name with a remote object. The client looks up the remote object by its name in the server's registry and then invokes a method on it. The illustration also shows that the RMI system uses an existing web server to load class definitions, from server to client and from client to server, for objects when needed.
    原理图

详细教程

https://docs.oracle.com/javase/tutorial/rmi/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,183评论 0 10
  • 我真的不知道怎么教育孩子了,快要抓狂了。越教育越反弹,一点效果也没有,也不知道是不是我太啰嗦了。 还是说对一个五岁...
    文无相邀阅读 1,693评论 0 0
  • 1,需求分析: 2,系统分析: 1>确定项目的技术框架,开发工具。 2>模块划分,各模块功能分析。 3>模块之间的...
    何wife阅读 1,621评论 0 0
  • 0问荆0阅读 1,819评论 0 0
  • 有人说:两个人在一起一天牵手漫步那是激情;在一起一年牵手漫步那是恋情;在一起五年还能牵手漫步那是感情;在一起十年牵...
    Lonely杜小杜阅读 4,272评论 0 0

友情链接更多精彩内容