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

Modifying the Tunneling Mechanism

The default RMI socket factory will automatically attempt to tunnel over HTTP when more straightforward ways of connecting fail. You don’t need to change the server or the client code. Instead, you simply need to make sure that a third server, which forwards the requests, has been installed and everything is configured correctly. Since all the code for this server is readily available, you may think that using HTTP tunneling boils down to an exercise in configuring your application. For the most part, this is true. In many cases, using HTTP tunneling boils down to installing the software and making sure all the servers are available. However, sometimes you will need to modify the tunneling mechanism. At this point, it is helpful to observe that the HTTP tunneling mechanism naturally divides into three parts:

The client

Posts a request to the web server

The servlet

Forwards the request to the RMI server’s socket, preserving the HTTP structure of the client post

The server

Automatically handles the HTTP post, in addition to ordinary JRMP commands

These three parts can change independently. The client will automatically post to the web server if it cannot reach the RMI server directly. This will happen regardless of whether the servlet performing the tunneling is Sun’s implementation or a custom version you wrote. Similarly, the RMI server will accept either JRMP method invocations or HTTP posts, whether or not they came from a servlet doing HTTP tunneling ...

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