rmiregistry
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Miroslav_Stoitsov
Posted On:   Tuesday, September 30, 2003 06:05 AM

Hi everybody,

Is it possible to use rmi client <->server setup without running the rmiregistry? Is it possible to pass and return remote object references as part of applicationĀ“s normal operation and if yes how? I would readily accept any suggestions or links to some example source code since all the examples I have found are using that registry.

Thanks in advance

Re: rmiregistry

Posted By:   Zac_Jacobson  
Posted On:   Wednesday, October 1, 2003 05:01 PM

You can, of course, pass any kind of object around within an application. If that object fullfills a remote method interface, then you have to have gotten that object from the registry, or you created it yourself. Once you have it though, you can use it however you want, pass it around, etc. I haven't personally tried passing a remote interface to another object via RMI, so I don't know if that works (I don't see why it wouldn't), but if you pass a locally created object that happens to fullfill that remote interface, then stuff done in the remote VM will not affect the object where it was created since the object itself will get serialized and sent rather than a stub that points back at the object.

RMI is slower than intra-VM method calls, so it doesn't make sense to use it for local objects and methods; if you keep a reference to your RemoteObject locally after you create it, you can certainly access it via that reference rather than through RMI.

If you need to use RMI, you don't have to use the supplied rmiregistry program, which has some shortcomings. You can instanciate and use your own registry.

// Create a registry
Registry r = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
// bind your object to it as normal.
r.rebind(name, remoteObject);
And now, locally only, you can access the same object without the RMI stub by using remoteObject.remoteMethod().

I hope somewhere I've covered what you've asked!

About | Sitemap | Contact