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
I Hear I Forget, I See I Remember, I Do I Understand.
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.
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?
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???.