my dog learned polymorphism
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Create 2 registry under different port? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Create 2 registry under different port?" Watch "Create 2 registry under different port?" New topic

Create 2 registry under different port?

HanMing Low
Ranch Hand

Joined: Oct 18, 2001
Posts: 196
I'm having a problem to create a Registry under 2 different port.
I'm trying to allow user to configure the server to bind to different port at runtime.
Thus, if he starts up in port 1099, he can use the GUI to switch to e.g. 1090.
However, if I use
The second time when it is call, it says "ObjID already in use".
But if I continue to rebind my Server object to the registry. It says NoSuchObjectException.
Can anyone advice how do I create a Registry that listen to another port when a Registry is already created.
And, is it possible to know if a Registry is already running on a specified port.
Thanks for any advice.

Han Ming
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

I couldn't find any method that would close the registry. Of course if you have

Registry reg = LocateRegistry.createRegistry(1099);
and then set reg to null, it might close it. But I don't have first hand knowledge that it will.
However, I would ask why you need to give the User the ability to change the port number once the server has already been started.
You can have the user put the port number in the command line as stated in the specs as allowed
These command lines may only take configuration parameters selected from this list:
DNS name of the server
Port number used by the server


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
HanMing Low
Ranch Hand

Joined: Oct 18, 2001
Posts: 196
Hi Mark,
Thanks for the advice.
I think you're right that there doesn't seem to be any method to drop the registry.
I guess I have to drop the feature in this case.
The reason I'm including the feature is not for the client but server rather.
I'm having a Server GUI that allow configuration to be made on the Server.
which db.db file it connect to
which port number
Thus, to allow the server to switch to a different port using the GUI, I need to unbind the object from registry, start a new registry at the new port and rebind the object at this new port.
But looks like there is a problem with the registry as executing
will cause an ObjID already in use for the 2nd statement.
Should it be like this?
I'm not sure actually, but I'd expect it to create a registry that bind to port 1099 and another to port 1090.
So, I guess it's a better idea to drop the feature.
Thanks again for your advice.
Han Ming
I agree. Here's the link:
subject: Create 2 registry under different port?
jQuery in Action, 3rd edition