One of the major themes of this book is that RMI, for all its power and convenience, is really just a layer implemented on top of the standard socket objects shipped with the JDK. In this chapter, I build on this theme by showing how to replace the standard (cleartext) sockets that RMI uses with other sockets. The fact that RMI allows you to do this, and to do this differently for each type of server, is a very powerful feature. By the end of this chapter, you’ll understand how to change the sockets that RMI uses and know when doing so is an appropriate design strategy.
As I’ve mentioned countless times, RMI is built on top of sockets. This means that:
Data sent between clients and servers (in both directions) is sent using a streams interface.
Connections between clients and servers are
created and maintained by using the socket classes
defined in the
RMI doesn’t make any assumptions about the underlying network infrastructure or communication protocol.
Understanding these points, and what they imply, is crucial for understanding how RMI works “under the covers.” However, the strict separation they imply between RMI on the one hand, and the operating system and network transport protocol on the other, also leads quite naturally to the following thought:
If I can define a new socket class, and my socket-level communications protocols will work with it, then my RMI applications, which are built on top of sockets and don’t make any ...