Java Reference
In-Depth Information
From Chapter 18 on RMI we know that the interface must extend java.
rmi.Remote and that each method declared in the interface must throw
java.rmi.RemoteException . Therefore, our FactoryInterface looks
like:
package javatech.all20.server;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface FactoryInterface extends Remote {
final static String FACTORY - NAME =
"all20ServerFactory";
public ServerInterface getInstance (String id)
throws RemoteException;
}
where we have used package javatech.all20.server , following the pattern
of Chapter 18. Here we have also defined the constant FACTORY - NAME ,which
contains the name that the factory will be bound under in the RMI registry.
Both the client and the server need to know the binding name, and defining it
here is convenient since both client and server can see the same name in the
same place, which is much preferred to defining the same name in two different
places.
20.3.2 The server interface
The server interface designed in Chapter 16 and clarified in Chapter 17 (see the
class diagram in Figure 17.3) has four methods:
package javatech.all20.server;
...
public interface ServerInterface extends Remote {
public boolean initialize (String initparam)
throws RemoteException;
public void initializeSimulation (float[] indata)
throws RemoteException;
public void start ()
throws RemoteException;
public float[] retrieveData (float[] indata)
throws RemoteException;
}
The initialize() and initializeSimulation() methods are almost
redundant in this simple example. Recall from Chapter 17 that initialize()
Search WWH ::




Custom Search