Java Reference
In-Depth Information
Figure 20.1 The server collaboration diagram. It is the same as in Figure 16.6
except for the insertion of the initialize () invocation as sequence number 3.
the code here is derived from actual working examples of complex simulations.
Sometimes the simplifications necessary to produce an example of pedagogical
value that can be discussed in a textbook setting result in the removal of features
that are quite valuable for real world cases. Rather than reduce the example sim-
ulation to an even more limited one, we have chosen to retain certain features
as placeholders for more complicated client/server solutions that the reader may
wish to put into practice.
20.5.1 The Server Class
The Server class is the class that implements ServerInterface and is the
only server-side object with which the client interacts directly. As normal in RMI
implementations it extends UnicastRemoteObject :
public class Server extends UnicastRemoteObject
implements ServerInterface
{ ... }
20.5.1.1 The Server constructor
The Server constructor is called by the factory upon demand from a client
during getInstance() .From the factory discussion above, we already know
the signature of the constructor. As required by RMI, the constructor, and all
methods declared in ServerInterface , must be declared as possibly throwing
RemoteException :
public Server (ServerFactory myfac, String id)
throws RemoteException {
fFactory = myfac;
fID = id;
Search WWH ::




Custom Search