• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Please Help! - Naming.rebind and Port

 
Bill Robertson
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using Max's code and info from some other posts I am trying to
start a user specified port (XXXX = any port) using:
java.rmi.registry.LocateRegistry.createRegistry(XXXX);
and then I make the call:
RecDatabaseImpl aRec = new RecDatabaseImpl();
Naming.rebind("RecMediator", aRec);
My question is how does the Naming.rebind("RecMediator",aRec) recognize
the port XXXX???
By simply calling java.rmi.registry.LocateRegistry.createRegistry(XXXX)?
I dont understand how the two calls automatically tie into eachother becuase
the Registry object returned by LocateRegistry.createRegistry(XXXX) is
never used. Instead the code simply moves on and calls
Naming.rebind("RecMediator", aRec);
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11941
211
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill
Max's code starts the RMI Registry on the "well known" port: 1099. The rebind is just using that well known port. It would not work if you used any other port.
This would be a good time for you to visit the Naming API - this will explain how you can specify the port number in the name that you use as a parameter to bind(), rebind(), lookup() ....
I suggest you look at that reference first, then come back with any questions after that.
By the way, the LocateRegistry.createRegistry() method returns a reference to the registry that is started, so you could call rebind() on that reference and then you would not need the port number either.
Regards, Andrew
 
Bill Robertson
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Andrew, I should have done more homework on this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic