简体   繁体   English

Java RMI的UnicastRemoteObject

[英]Java RMI's UnicastRemoteObject

I am currently practicing the implementation of RMI in Java. 我目前正在练习Java中RMI的实现。 One of the requirements is to create a class that extends the UnicastRemoteObject which contains functions that can be called remotely. 要求之一就是创建一个扩展UnicastRemoteObject的类,该类包含可以远程调用的函数。

I'd like to know if the class that extends the UnicastRemoteObject is shared by all connected clients. 我想知道扩展UnicastRemoteObject的类是否由所有连接的客户端共享。 What I mean by sharing is that, is the instance object created from the class that extends the UnicastRemoteObject is concurrently used by connected clients? 共享的意思是,从扩展UnicastRemoteObject的类创建的实例对象是否由连接的客户端同时使用?

It depends how you use it. 这取决于您如何使用它。 Normally if that's the only remote object, you would register a single instance of it in the RMI Registry, then the clients look it up and call methods on it, and they are all sharing the same instance. 通常,如果这是唯一的远程对象,则可以在RMI注册表中注册该对象的一个​​实例,然后客户端在该对象上查找并调用方法,并且它们都共享同一实例。 However if you look at this question and answer you will see how to allocate one per client, if that's your requirement. 但是,如果您查看此问题并回答,那么您将看到如何为每个客户分配一个(如果您有此要求)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM