O'Reilly logo

Java RMI by William Grosso

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Class Server

Implicit in the discussion so far is the idea that a class file can be downloaded from a URL. That is, from a codebase annotation for a class, which contains a string-delimited sequence of URLs, and a classname, the RMI deserialization algorithm can find and load a class. I’ve already mentioned that RMI uses instances of the URLClassLoader class to do this. In this section, we will discuss how URLClassloader works, and how you can create a server that responds to requests from a URLClassLoader.

In the discussion that follows, we will assume that all URLs are of the form http://. Instances of URLClassLoader can also handle URLs of the form ftp://. The decision to focus on http:// URLs has two justifications. First, most applications use http:// rather than ftp:// URLs. Second, ftp:// URLs are handled in pretty much the same way anyway. If you understand how the http:// URLs are handled, you can figure out the ftp:// URLs in under 10 minutes.

Requesting a Class

At this point, it’s important for us to discuss how HTTP works in a little detail. The important points are these:

  • HTTP works in request-response cycles. A client makes a request, typically through a GET or POST request, and a server sends back a response. After the response is sent, the connection is over, and there are no obligations on either side.

  • HTTP is an ASCII-based protocol. An HTTP message consists of a series of ASCII headers followed by a stringified version of any binary data that may ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required