File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Distributed Java and the fly likes LocateRegistry.getRegistry (1234); Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "LocateRegistry.getRegistry (1234);" Watch "LocateRegistry.getRegistry (1234);" New topic

LocateRegistry.getRegistry (1234);

Charlie Goth
Ranch Hand

Joined: Feb 26, 2004
Posts: 60
I'm running this code which returns a Registry, is there an easy way of telling there is actually a registry running? I assumed it would return null if there isn't one on localhost port 1234. At the moment I'm having to call list() on the returned registry, using a thrown exception to indicate there's no registry bound on that port.

SCJP (77%)
Chris Shepherd
Ranch Hand

Joined: Jun 27, 2000
Posts: 286
Thanks Charlie, I think your question just answered a question that was posed in another post.
I think you've got about the only way to detect an actual registry. The docs essentially state that there is no way to know if you actually hook up to a real registry. You could streamline the process a little by going ahead and trying to rebind your server to the returned registry object and watching for an error from that. If it threw errors, just programatically start a new registry in the catch() section and do the same rebind process over again.
It should work pretty well.
I agree. Here's the link:
subject: LocateRegistry.getRegistry (1234);
It's not a secret anymore!