my dog learned polymorphism*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RMI: rmiregistry, LocateRegistry, Naming and policy files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "RMI: rmiregistry, LocateRegistry, Naming and policy files" Watch "RMI: rmiregistry, LocateRegistry, Naming and policy files" New topic
Author

RMI: rmiregistry, LocateRegistry, Naming and policy files

Marcos Motta
Ranch Hand

Joined: Apr 28, 2002
Posts: 56
I am trying to figure out the best way to bind my server to the Registry. I see three options:
1) My server does not create a registry, it uses the registry on default port 1099 previously create by rmiregistry.
2) The server always create the registry using LocateRegistry.createRegistry()
3) Always try to create the registry at port 1099 ignoring any exception and, after that, bind to the registry using Naming.rebind(). This way my server can use an external registry (in another VM) or create one as needed. Example:


One last thing: Do I realy have to setup a RMISercurityManager and provide a policy file? So far my client and server are working perfectly without any of these. (I am using jdk1.3.1)
Suggestions are very welcome
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
2) The server always create the registry using LocateRegistry.createRegistry()
That's the approach that I would advise because it's one less thing to document. The simpler your start up instructions the better. If you don't do that you will have to explain how to start the registry. I used that approch and made the registry port a command line option which defaulted to 1099 (if the port were not entered on the command line).
One last thing: Do I realy have to setup a RMISercurityManager and provide a policy file? So far my client and server are working perfectly without any of these. (I am using jdk1.3.1)
Nope. I did in mine, but it is not necessary. Once again, it's one less thing to document. The simpler, the better.


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Marcos Motta
Ranch Hand

Joined: Apr 28, 2002
Posts: 56
Thanks Michael
 
jQuery in Action, 2nd edition
 
subject: RMI: rmiregistry, LocateRegistry, Naming and policy files