The Arith Interface

Methods to be invoked remotely, must be declared in an interface such as this. A server can have non-remote methods, but these cannot be accessed by remote clients. (Of course they can be used locally on the server.)

All remote interfaces must extend java.rmi.Remote and must throw RemoteException. Any remote invocation may fail because it may not be able to connect to a server, perhaps because the server is down or it is overloaded.

N.B. A RemoteException is a so-called checked exception. It must be caught by any code that uses a method which throws it.

The remote interface must be declared public. Otherwise, clients will not be able to load remote objects which implement that remote interface.


package mahmoud.ch8;
/**
 * @(#) Arith.java
 * @author Qusay H. Mahmoud
 */
public interface Arith extends java.rmi.Remote {
    int[] add(int a[], int b[]) throws java.rmi.RemoteException; 
}

The developer of the client, who may be a different person, on a different machine, than the developer of the server, must have access to this interface, either in source or compiled (.class) form.