UnicastRemoteObject.exportObject expose a remote object at given ip and port
LocateRegistry.getRegistry.bind register a remote object to registry, note that registrty is also a remote object, and the registry service need to be started in advanced.
set CLASSPATH=D:\workspace\BuGu\bugu_core_test\bin
start rmiregistry
LocateRegistry.createRegistry(1099);
can i specify ip and port instead of using registry?
can it be bi-directional?
client expose a object implemented Remote interface or use a object extends UnicastRemoteObject.
can bi-direction works when client is behide a gateway or firewall?
RemoteObject contains reference to RemoteRef, and provide re-implementation for Object's method.
RemoteRef handles calling methods on a remote object, subclasses of RemoteStub and RemoteObjectInvocationHandler (Used to create proxy) deletgates method call to this object.
Stub and proxy can be published on server and then be serialized to client?
Class that do not extends UnicastRemoteObject will not has it's equals/hashcode... methods implemented correctly
Besides RemoteStub and RemoteObjectInvocationHandler, why RemoteServer need to extends RemoteObject?
Know that UnicastRemoteObject don't need a RemoteRef in constructor, this means that it creates a implementation of RemoteRef by itself.
Stub will contain RMIClientSocketFactory, which will be serialized to client and be used to create socket connection.
When passing an exported remote object as a parameter or return value in a remote method call, the stub for that remote object is passed instead. Remote objects that are not exported will not be replaced with a stub instance.
Within a single remote method call, the RMI system maintains referential integrity among the objects passed as parameters or as a return value in the call.
When an object is sent from one JVM to another in a remote method call, the RMI system annotates the class descriptor in the call stream with information (the URL) of the class so that the class can be loaded at the receiver. It is a requirement that classes be downloaded on demand during remote method invocation.
RMI’s subclass of ObjectOutputStream also implements the annotateClass method that annotates the call stream with the location of the class so that it can be downloaded at the receiver.
This is why only java5 don't need to create stub manually?
The ObjectOutputStream subclass overrides the replaceObject method to replace each exported remote object with its corresponding stub instance.
A stub for a remote object is obtained via a call to the method java.rmi.server.RemoteObject.toStub.
Registry use Naming?
Why need to register a stub not the orginal object?
skeletons are not used since 1.2, ignore it.
A remote object implementation needs to make sure its implementation is thread-safe.
RMI uses a referencecounting garbage collection algorithm, the counter increase when stub is created and descrease when stub is claimed. When remote object's counter is zero, RMI changed to use a weak reference to hold it, therefore, if there's no local reference to it, it can be claimed by JVM at anytime!
Implement java.rmi.server.Unreferenced to get notified when no client refers to it.
The RMIClassLoader provide methods to get the codebase and load class from codebase.
RMISocketFactory
First, a direct socket connection to the remote VM is attempted. If that fails (due to a firewall), the runtime uses HTTP with the explicit port number of the server. If the firewall does not allow this type of communication, then HTTP to a cgi-bin script on the server is used to POST the RMI call.
分享到:
相关推荐
RMI(Remote Method Invocation,远程方法调用)是Java平台中的一个重要特性,它允许Java对象在不同的Java虚拟机之间进行通信,实现分布式计算。RMI是Java开发分布式应用程序的基础,尤其在构建分布式服务和微服务...
Java RMI(Remote Method Invocation,远程方法调用)是Java平台提供的一种分布式计算技术,它允许Java对象在不同的网络环境中进行交互,就像它们在同一个进程内一样。RMI是Java在分布式系统领域的核心特性,极大地...
根据提供的文件信息,我们可以深入探讨Java RMI(Java Remote Method Invocation)的相关知识点,包括其概念、原理、体系结构以及一个具体的示例。 ### RMI的概念 RMI是一种Java技术,它允许开发者创建分布式应用...
Java RMI(远程方法调用)是Java编程语言中的一项核心技术,自JDK 1.1版本起就被引入,用于构建分布式系统。RMI允许Java对象在不同的Java虚拟机(JVMs)之间进行交互,仿佛这些对象是在同一台机器上一样。这种技术的...
### Java RMI (Remote Method Invocation) 概念与实践 #### 一、Java RMI简介 Java RMI(Remote Method Invocation)是一种允许调用不同Java虚拟机(JVM)上方法的机制。这些JVM可能位于不同的机器上,也可能在同一...
Java RMI(Remote Method Invocation,远程方法调用)是Java平台提供的一种分布式计算技术,它允许在不同的Java虚拟机之间进行远程对象的调用。RMI使得开发者可以像调用本地对象一样调用网络上的对象,极大地简化了...
Java RMI (Remote Method Invocation) 是一种用于在Java应用程序之间进行远程通信的技术。为了提高RMI通信的安全性,我们可以使用SSL (Secure Sockets Layer) 或其后继者TLS (Transport Layer Security) 进行加密。...
Java Remote Method Invocation (RMI) 是Java平台提供的一种分布式计算技术,它允许Java对象在不同的网络环境中进行交互,实现远程方法调用。本压缩包文件"rmi-code"包含了一个完整的RMI测试代码示例,适合在Linux和...
Spring Remote Method Invocation(RMI)是Java平台上的一个远程对象调用框架,它允许一个Java对象在一台机器上执行,并且被另一台机器上的客户端调用。在这个"SpringRMI小例子"中,我们将深入探讨如何利用Spring...
分布式实验报告 RMI.docx 本实验报告主要介绍了 Java RMI(Remote Method Invocation,远程方法调用)的基本概念和实现步骤。RMI 是一种分布式对象通讯机制,允许运行在一个 Java 虚拟机的对象调用运行在另一个 ...
在Spring框架中,远程方法调用(Remote Method Invocation, RMI)是一种使应用程序能够通过网络调用另一个JVM上的对象方法的技术。RMI是Java平台的一部分,它允许开发者创建分布式应用,使得对象可以像调用本地方法...
Ehcache RMI Replicated Cluster 是一种分布式缓存解决方案,它使用远程方法调用(RMI)技术在多个节点之间复制数据,以实现高可用性和负载均衡。在大型分布式系统中,缓存是提高应用程序性能的关键组件,因为它可以...
**RMI原理及应用详解** 远程方法调用(Remote Method Invocation,简称RMI)是Java平台提供的一种分布式计算技术,允许在不同的Java虚拟机(JVM)之间进行对象方法的透明调用。RMI的核心思想是使Java对象能够跨越...
**基于JAVA RMI的聊天室** Java Remote Method Invocation(RMI)是Java平台提供的一种用于在分布式环境中调用远程对象的方法。在这个“基于JAVA RMI的聊天室”项目中,开发者利用RMI技术构建了一个简单的多用户...
Spring RMI(Remote Method Invocation)是Java平台上的远程方法调用技术,结合Spring框架的特性,使得在分布式系统中调用远程服务变得更加便捷。在这个简单的例子中,我们将深入理解Spring RMI的工作原理以及如何...
Java RMI(Remote Method Invocation)技术是Java平台中用于分布式计算的一种机制,它允许一个Java对象调用远程计算机上的另一个Java对象的方法。在本案例中,“java RMI技术实现的网络聊天室”是一个使用RMI构建的...
Spring RMI服务是一种在Java平台上实现远程方法调用(Remote Method Invocation, RMI)的技术,它允许分布式系统中的不同组件通过网络进行通信。在Spring框架的支持下,我们可以更方便地将服务发布为RMI服务,使得...
Java RMI(Remote Method Invocation,远程方法调用)是Java平台提供的一种分布式计算技术,它允许在不同的Java虚拟机之间进行方法调用,仿佛这些对象都在同一台机器上。RMI是Java网络编程的重要组成部分,使得开发...
本项目实例是基于RMI技术实现的一个服务器端程序,名为"RMIServer",提供了远程服务的接口和实现,下面将详细介绍RMI的基本概念、工作原理以及如何通过这个项目实例来学习和应用RMI。 1. **RMI基本概念**: - **...