Java RMI: How can I restrict RMI method to only be called internally by the client object

旧街凉风 提交于 2019-12-24 07:29:09

问题


I have an RMI model which uses a thread on each side (Client/Server Side) to maintain a client heartbeat. If the client crashes without unlocking the server, the lock will eventually timeout.

I don't want the user of my client API to be able to call the methods that deal with the heartbeat/lock. However from my understanding of Java RMI, the client and server must implement a common interface which defines all the methods that I want RMI access to, and these methods must be public. Since the interface defines these methods as public, the client methods must also be public, and can not be hidden from the user.

Question:

Is there a way to restrict certain methods that have been exported over RMI so that only the client object itself can call them? In other words, can I make the method act as though it is private on the client side?

来源:https://stackoverflow.com/questions/43400533/java-rmi-how-can-i-restrict-rmi-method-to-only-be-called-internally-by-the-clie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!