Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about RMI

 
Roger Fed
Ranch Hand
Posts: 82
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I've one question regarding RMI:
while reading about this technology ,some problems arises to me in understanding how does it work especially this line:
For an object to be invoked remotely, it must be defined in a Java interface accessible to both the server and the client
Why we have to define a java interface instead of using a class that directly implements Remote interface???
I'm confused in this ..
I'd be grateful if you can help me
 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The class that is going to be invoked sits on the server, but the client also needs to know what the methods are. The client doesn't need any information about the implementation of the class, so distributing the class to the client is inappropriate. It just needs to know the interface.

So you define and distribute the interface. Then on the client side, the RMI framework will create a stub class for you that implements that interface. You call the methods on that, and the stub sorts out the communication with the server for you.
 
Roger Fed
Ranch Hand
Posts: 82
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks "Matthew Brown" very much for your valuable help.
but I've another questions:
When the client look for a server object in RMI registry and locate it , it return a server stub.
What is the meaning of server stub?
second:
I know that when Developing RMI applications we must Define a server object interface that serves as the contract between the server and its clients, as shown in the following outline:

Why the server object interface must extend the java.rmi.Remote interface???.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic