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
Firstly, binding & rebinding remote object using Naming
class and Registry
class is not relevant to scenarios of whether or not a class is extending UnicastRemoteObject
. See here for the differences.
Secondly, the difference between the class extending UnicastRemoteObject
is that if the object of that type is used as a stub, then you'll not need to call UnicastRemoteObject.exportObject
to obtain the stub anymore for binding with registry. In your version 1, the StorehouseImpl
must have extended the UnicastRemoteObject
, and in fact, there's no need for EchoImpl
to extend UnicastRemoteObject
for your version 1 as there is no instance of EchoImpl
is registered as a remote object to the registry.
Thirdly, you mention what'd happen if rebind
is executed without bind
is executed beforehand. As explained in the javadoc here, if no key name has been inserted, it will behave in the same way as if first time bind
is executed.