Remote Method Invocation (RMI) Flashcards
What are the imports for the RMI interface?
import java.rmi.Remote;
import java.rmi.RemoteException;
Give the interface signature
public interface RemoteEcho extends Remote {
What exception is thrown by the interface stub
RemoteException
What are the imports for the RMI implementation class?
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
Give the RMI implementation class signature
class RemoteEchoServant extends UnicastRemoteObject implements RemoteEcho {
What is the comment / annotation on RMI implementation methods
@Override
What are the imports for the main class on the server side?
import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
Give the first line of the try block on the server
RemoteEcho rei = new RemoteEchoServant();
What are the imports for the main class on the client side?
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
Give the statement to create the registry on the client
Registry reg = LocateRegistry.getRegistry(“localhost”, 1099);
Give the statement to create the service on the server
Registry reg = LocateRegistry.getRegistry(“localhost”, 1099);
Give the statement to find the service on the registry from the client
Registry reg = LocateRegistry.getRegistry(“localhost”, 1099);
Give the statement to bind the registry on the server
reg.rebind(“echoServer”, rei);
Give the statement to lookup the registry in the client
Object o = reg.lookup(“echoServer”);
Give the first line of the main class in the client
RemoteEcho rei = null;
Give the statement to invoke the remote method from the client (reflect)
String s = rei.reflect(buf);
What is a callback?
Callback refers to the server’s action of notifying clients about an event
How can Callbacks can be implemented in Java RMI?
♦ Client creates a remote object that implements an interface containing a method for the server to call (callback object)
♦ Server provides an operation allowing clients to inform it of the remote object references of their callback objects. It records these in a list
♦ Whenever an event of interest occurs, server calls the interested clients
Advantages of Callbacks are :
♦ Server performance does not degrade due to constant polling
♦ Clients can be notified of updates in a timely manner
Disadvantages of Callbacks are :
♦ Server needs up-to-date list of clients’ callback objects; clients do not inform the server when they exit; leasing can be used to overcome this problem