Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI Registry

 
birmingham city
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please could you explain this to me in basic english.thanks
public static Registry getRegistry(int port) throws RemoteException
{
Registry registry = null;
try {
registry = LocateRegistry.getRegistry(port);
registry.list();
}
catch (Exception e) {
System.out.print("Registry not found on port " + port);
System.out.println(" - creating one...");
registry = LocateRegistry.createRegistry(port);
}
return registry;
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Birmingham city" -
Please take a moment to review JavaRanch's naming policy, and change your name accordingly; thank you.
The code above locates an RMI registry on the local system. The list() call normally returns a String[] of named services already bound to the registry. In this example the return value is ignored, so perhaps it's invoked to provoke a possible exception.
The catch code sets up a registry if one is not found by the code in the try block. This runs a registry without establishing having to do it from the command line. This approach has become particularly popular with people who a) are testing RMI code and want to keep things manageable from one place; and b) people who want a compromise between the cumbersomeness of 'regular' RMI and the administrative control necessary to run an RMI activation daemon.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic