This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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.
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
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