Java Reference
In-Depth Information
The RMI registry helps you deploy your server side code dynamically—using the Registry
class's rebind method allows you to load the new server functionality with a minimum of
downtime. With a sockets solution you would either have to stop the old server and then start
the new server (with a longer downtime than RMI's rebind ), or use a different socket port
(which would require reconfiguring or replacing clients).
Using RMI frees you from the requirements of specifying which port a particular service
will be available on. With a sockets solution you must specify which port your server will be
listening on, and the clients must make a connection to that port. If you do not make this con-
figurable and some other application is developed in such a way that it uses the same port
(and is also not configurable), then one or the other will have to be recompiled. Even if the
port number is reconfigurable you would have to reconfigure all the clients to use the new
port number, which may not be easy or practical. RMI solutions, by default, use random port
numbers for the servers, where the port number is specified by the RMI registry. The clients
need only know the port number of the registry, which they then query to determine how to
contact the server they are interested in.
Although not permitted within the SCJD assignment, RMI allows you to download exe-
cutable classes. You could use it, for instance, to download some security algorithm that will
encrypt all the data between clients and server—since the code is downloaded dynamically,
the programmer for the client side never gets to see how you implemented it (indeed, you
could even hide the fact that it is being used at all), thus reducing the chances of someone
trying to hack your encryption algorithms if they never get to see them.
Choosing Between the Two Solutions
Probably by now you have seen that there are good arguments for both solutions, and no
absolute differentiator between either. We believe that Sun has deliberately done this to see
your decision-making logic.
You must decide which of the arguments we've listed (or others that you determine for
yourself ) make the most sense to you, and which of them you are willing to defend if you are
asked to explain your decision.
The MVC Pattern in the GUI
Chapter 8 covered GUI-related design decisions ranging from general information on inter-
face layout principles all the way to the discussion of specific Swing components, such as the
JTable . Unlike the choice between an RMI and a sockets-based network implementation (dis-
cussed in Chapters 6 and 7 as well as earlier in this chapter), Sun literally requires the use of
the JTable in order to pass the SCJD exam, so the decision to use it is a no-brainer if you want
to pass the exam.
Search WWH ::




Custom Search