Java Reference
In-Depth Information
the problem improved. Such name changes are common during OOAD and
should not be eschewed. The proper and sensible naming of objects and opera-
tions is important for a clear understanding of a design.) When the client calls
initializeSimulation()
, the server performs sequence 3, which initializes
the
SimulationThread
with the input data:
public void initializeSimulation (float[] indata)
throws RemoteException
{
fSimulationThread.initialize (indata);
}
20.5.1.4 The
Server.start()
method
Finally the client calls the server's
start()
method in order to start the sim-
ulation running. This call is forwarded immediately to
SimulationThread
's
start()
method at sequence 4 in the collaboration diagram.
public void start() throws RemoteException {
fSimulationThread.start();
}
As usual, calling a thread's
start()
method invokes the
run()
method, which
we show later.
20.5.1.5 The
retrieveData()
method
As the simulation runs, simulation data is repeatedly loaded into the
SimData
object as shown in sequence numbers 4.2.1 and 4.2.1.1. We explain those details
shortly. For now, we assume that the client periodically polls the server for current
simulation data. The client does so by calling
retrieveData()
,which simply
obtains and returns the latest available data from
SimData
using its (yet to be
discussed)
getResults()
method (shown as sequence 5 in the collaboration
diagram of Figure 20.1):
public float[] retrieveData (float[] indata)
throws RemoteException
{
return fSimData.getResults (indata);
}
Here we have made the simplifying assumption that the set of data to be returned
is a simple
float[]
array. More complicated structured data could be returned
in a Java object with minor modifications. We have also taken the opportunity to
allow the client to provide a new set of input data during each
retrieveData()
poll. If the input data has not changed, then the original
indata
array can be
passed each time.
Search WWH ::
Custom Search