code: private Registry getRegistry(int port) throws RemoteException {
          Registry reg;
          String hostName = System.getProperty("java.rmi.server.hostname");
          if (hostName != null && !hostName.isEmpty()) {
              reg = LocateRegistry.getRegistry(hostName, port);
          }
          else {
              reg = LocateRegistry.getRegistry(port);
          }
          return reg;
      }
docs: shared utility module