*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Create 2 registry under different port?" Watch "Create 2 registry under different port?" New topic
Author

Create 2 registry under different port?

HanMing Low
Ranch Hand

Joined: Oct 18, 2001
Posts: 196
Hi,
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
LocateRegistry.createRegistry(portNumber);
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.
Cheers.

Han Ming
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
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.
e.g.
which db.db file it connect to
which port number
etc.
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
LocateRegistry.createRegistry(1099);
LocateRegistry.createRegistry(1090);
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.
Cheers.
Han Ming
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Create 2 registry under different port?
 
Similar Threads
createRegistry()
NX:RMI-How to keep the RMI factory service running always?
How to close a rmi registry with codes???
RMI experts-> createRegistry and a stupid argument...
client - server communication between two machines