Observers And Rmi

hello!

A while ago I posted the claim on the RemoteMethodInvocation mailing list that I had implemented a system using RMI where the Stubs could cache data and implement their own behavior--not something you can normally do because the stubs are automatically generated. You can of course write your own wrappers on RMI StubObjects but the rmi transport layer will not instantiate your wrappers so you have to do a lot of housekeeping to manage two different kinds of ProxyObject?s, the thin stub and the intelligent proxy.

My solution basically has rmi instantiating your proxy objects, which are themselves wrappers on the thin stubs. The distinction is transparent to clients of these objects.

Furthermore the solution utilizes a generic messaging system to broadcast changes from implementations to their intelligent proxies to keep them synchronized.

I got several responses from people who wanted to know more. I sent this overview to them. I don't know how useful this is, but if I got more encouragement I might write a paper on it.

Here's the overview:

First, I modified the rmi compiler so that it compiled stubs to files named XXX_ThinStub.java instead of XXX_Stub.java. The trick here is that the rmi code still tries to instantiate XXX_Stub classes to create the stubs. This allows you to insert your own wrapper class on ThinStub? which does the correct remote dispatching.

In my XXX_Stub classes, I intercept calls to addObserver, etc., which I forward to a local dispatcher. This local dispatcher subscribes to changes on this object using a traditional publish/subscribe mechanism (in our case, Tibco's Rendezvous). Other changes are passed through.

On the server side, implementation objects have a notifyObservers() method which notifies local observers but also "publishes" the changes to the network so that subscribers, on behalf of their local observers, can forward the notification.

The end result was observable objects whose actual location was transparent to observers. Observable objects had to implement Remote, but Observers didn't.


Take a look at the article, http://www.javaworld.com/javaworld/jw-11-2000/jw-1110-smartproxy.html, for a way of accomplishing the same thing, without changing the rmi compiler or doing post-code-generation editing.


RmiPatterns


EditText of this page (last edited September 10, 2003)
FindPage by browsing or searching

This page mirrored in JavaIdioms as of April 29, 2006