|
java.rmi A Remote Method Invocation Guide
Esmond Pitt and Kathleen McNiff Addison Wesley 2001 ISBN: 0-201-70043-3
Review by Spiro Michaylov
spiro AT michaylov DOT com
Java RMI is an important and complex topic that many developers find surprisingly troublesome. Often, they already find distributed programs hard to think about, and then there are all the details. Which class should I be extending here? Which interface should I be implementing there? Do I really need to run an HTTP server? What needs to be in the codebase? Where do the stubs need to be available? How do I avoid distributing too much code to clients? What do I put in a policy file and where must it be accessible?
Even after one becomes comfortable with these basics (and yes they are all basics) there are lots of advanced topics like activation, security issues, firewalls, socket factories, datagrams, multicast, proxies. Because it’s a fairy deep topic for most developers, there’s room for two kinds of books on RMI.
- A tutorial introduction for those who are new to RMI and perhaps even new to distributed programming, making it as easy as possible for them to develop basic client/server systems and have a fair understanding of how and why they work, how to trouble shoot them, etc.
- A detailed treatise on every aspect of RMI, organized systematically so it can be used as a reference.
Of course, there’ll always be the temptation to solve both problems in one book, with varying amounts of success for each reader.
This books is rather successful in meeting the second goal. It seems to be the most comprehensive collection of information about RMI available anywhere. On the whole, it is quite well organized, and quite approachable for someone who is already comfortable with using RMI and has been using it for some time. The book provides lots of technical insight, and discusses lots of “gotchas” for readers at all levels.
The authors have also attempted to make the book useable as an introduction first time RMI users. In this they have been rather less successful. Thankfully, this compromise doesn’t harm the book as an advanced text. What might otherwise have been single chapters on security and naming have been split into two chapters each, with the more basic material in relatively early chapters and the advanced material in much later chapters. Similarly, there are four chapters on RMI servers, sensibly spread through the book. The book remains very useable as a reference. Individual topics are quite easy to find, partly because the sections are kept short.
First time RMI users will find the book problematic for a number of reasons. Basic and advanced material are interspersed without any attempt to make a clear distinction between them. For example, to understand enough about RMI to write a simple example and execute it correctly (stubs loaded via the codebase), you need to reach around about page 101 of 284. But to get there you have to get through more advanced topics like threading issues, socket factories, explicit export, registry listing utilities, and custom serialization and versioning -- even though a simple client and server can be written without the programmer having to create a single Serializable class.
There are numerous code examples, but they’re used sporadically. The rather comprehensive discussion of the RMI registry contains exactly one piece of code, on the tenth page of the twelve page chapter, and this is a utility for listing the contents of the registry. Novice RMI users would benefit from a somewhat interesting and realistic example being built up and carried through the book. They would also benefit from diagrams to help them keep straight what is running where, which code gets loaded from where, etc.
A more serious treatment of certain pragmatic issues would also be helpful. For example, novices often have trouble figuring out how to build and run an RMI project. They would benefit from a systematic treatment giving the full details of the commands needed -- or maybe even Ant files. Teaching programmers to organize their projects into client side and server-side JARs and downloaded JARs at an early stage would also help them to develop good habits. Likewise, an early taste for using RMI registries with empty CLASSPATHs helps catch basic problems. Instead, the authors recommend using an embedded registry in early development (page 61) to put off understanding code mobility. This is an interesting idea, and perhaps reasonable, but perhaps would have worked better if a “toy” RMI based program without code mobility had been introduced in say the first twenty pages, and then a “real” one using a free standing registry in the next twenty. Taking almost half of what is after all an advanced book to get “real” seems a bit strange.
Basically, anybody new to RMI would get more help in starting to use it from Sun’s online tutorial and FAQ.
Summary
This book should be on the shelf of every Java RMI user as a reference and as educational reading. It may be of some help to novice users, but is probably not the best introduction to RMI.
|