问题
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