Up Previous Next

Before we even talk about starting it, the server needs to be of a certain type.

import java.rmi.*;
import java.rmi.server.*; 
import java.rmi.registry.*; 

public class Server extends UnicastRemoteObject implements ServerInterface {

  public Server() throws RemoteException { // constructor does nothing...
    System.out.println("Server being initialized..."); 
  } // its only purpose is to acknowledge the exception at creation time 

  public synchronized int register(ClientInterface client) throws RemoteException {
    size++;
    return size; 
  } 

  int size = -1; 

  public static void main(String[] args) {

  } 
}
We see these changes, important as they are, are entirely decorative.

We already had the (default) no-arg constructor, and acknowledging the exception thrown does not affect its contents.


Up Previous Next