• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rmiregistry and server

 
Zhaozhe Ruan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could anyone tell me if i can start the server without run rmiregistry first?

i wanna start the server with "localhost" "port"
but if I rum "rmiregistry 1024", i could only assign the "port" 1024, or I can not start the server
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use LocateRegistry.createRegistry(int port) method.

For instance, this codes creates a new RMIRegistry, and registers a Server object with it:



To shut down the RMI registry, I unexport the registry object.


I hope this helps!
 
Oricio Ocle
Ranch Hand
Posts: 284
Debian Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can export multiple remote objects in the same port.

Regards
 
Zhaozhe Ruan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've tried your way, but when I try to connect from client to server, connection was refused, could you give me some suggestions?

thanks
 
Daniel Bryant
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Zhaozhe,

In answer to your original question, if I understand correctly, what you want to do is start the RMI registry using a user-defined port number?

If this is the case I would recommend displaying a GUI to the user (created and displayed by an object i.e. ApplicationRunner.java with a main method that is not the server and does not require RMI to be running) and then ask for the appropriate information (url, port), and only then do you need to start the registry and instantiate your server object using the GUI object.

Best wishes,

Daniel
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zhaozhe, comrade.

The answer to your last question is fairly evident. If you create the RMIRegistry and bind your objects and you simply let your program finish then your server dies.

You have to make sure your application will not die until you want so.
For instance (this is just for an example), put System.read() at the end of your server initilization code, so that your server dies until you press enter.




Evidently you will have to provide some way to the end user to shut down the server when he wants.

This will require a shutdown strategy in order that any pendant transaction is completed before the server dies, and no further transactions should be accepted while the server is shutting down.

I hope this helps!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic