What is a remote object? Why UnicastRemoteObject should be extended?
by, 01-02-2012 at 07:34 PM (6345 Views)
Remote object is considered to be the one in which other JVM are used to invoke the methods. Remote interface gets implemented by the remote object class. RMI is that application that produces various remote objects.
Responsibility of a RMI Server is:
• To create the remote object’s instance e.g CarImpl instance = new CarImpl()).
• Export the remote object.
• Bind the remote object instance to the RMI registry.
Client’s incoming calls are being accepted when remote object is exported. Remote object might be exported by extending java.rmi.server.UnicastRemoteObject, or when the class has been extended you might make use of static method.
In case UnicastRemoteObject doesn’t get extended (you use UnicastRemoteObject.exportObject(…) ), it means that for the correct hashcode(), toString() and equals() implementations, responsibility rely upon class implementation. In RMI registry, a remote object gets registered by using:
Naming.rebind(String serviceName, Remote remoteObj);