Java Reference
In-Depth Information
Figure 16.4
Collaboration diagram illustrating the use of the naming service.
lookup of the requested service by name. The registered name of the desired
factory server must be known by the client seeking a server, much like you must
know the URL address of a web server to which you wish to connect with your
browser.
We can now expand our collaboration diagram to illustrate the presence of a
naming service as in Figure 16.4. Here the first sequence number is the client
requesting a lookup of the named factory server from the naming service. At
sequence 1.1, the naming service locates the requested factory (a singleton),
which is then returned to the requesting client. This diagram makes clear how
the client obtained the reference to the factory server used in the simplified
collaboration diagram in Figure 16.4. Then sequence numbers 2 and 2.1 duplicate
what we called sequences 1 and 1.1 in the earlier diagram.
In this more complete diagram we've also introduced the iteration notation
on sequence number 3. The asterisk means that this step can be performed mul-
tiple times. For example, the client probably makes several calls to the server
to obtain multiple results. A good example is when the server performs an
iterative or time-dependent calculation. Each call to the operate() method
might return status information or the current results of the time-dependent
calculation.
Here, too, we have glossed over some details. How, for instance, does the
naming service actually find the ServerFactory ? Those details are private to
the naming service and differ for the different naming services available. The
important thing to note is that when the ServerFactory is created it must
register with the naming service in some way. Just how this registration is done is
dependent on the naming service, but once an object has successfully registered
Search WWH ::




Custom Search