Java RMI - UnicastRemoteObject: what is the difference between UnicastRemoteObject.exportObject() and extends UnicastRemoteObject?

后端 未结 4 1582
暖寄归人
暖寄归人 2021-02-05 08:46

i\'m preparing for an exam and I\'m having a question that I hope someone here could answer me.

It\'s about RMI and remote objects. I wonder why there is so much differe

4条回答
  •  南方客
    南方客 (楼主)
    2021-02-05 09:42

    There are two questions here.

    1. You can either extend UnicastRemoteObject or call UnicastRemoteObject.exportObject(). Which you do is up to you. The first is simple and automatic; the second means you can extend another class.

    2. You can either use an external RMI Registry or create it yourself inside your server JVM. Again which you do is up to you, there are advantages both ways.

      These two questions have no interaction.

    3. If you extend UnicastRemoteObject you also get the benefit of 'remote semantics' for the hashCode() and equals() methods, such that all stubs appear to be identical to the remote object that exported them, but this is of no practical use on the client side, and is really only there to support the RMI implementation itself.

提交回复
热议问题