Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

UnicastRemoteObject  RSS feed

 
Patrick Wang
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am confused about the RMI UnicastRemoteObject,
I know a client can look up a server which create a object whose class extends remote, the object then casted to a remote interface and passed back to the client, then client was able to manipulate the remote interface.
Why there is a need to let the object's class extends
UnicastRemoteObject, without extending the UnicastRemoteObject, it seems to work anyway.
public class A implements IA(RemoteInterface)
{extends UnitcastRemoteObject} *******What do we gain by adding this line.
Server B {
main() {
x= new A();
return (IA) x;
}
}

Thx
Pat
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no need to extend UnicastRemoteObject, actually. What you do need is to be able to export the object in question, which can be satisfied with the static call UnicastRemoteObject.exportObject(). Without that piece, the object itself would not bind as necessary to the registry server.
It is possible to make things work without doing this, but only if the client and server code are on the same machine and able to see the same classpath.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!