if (registry == null) {
try {
registry = LocateRegistry.getRegistry(port);
port = 0;
} catch (RemoteException nested) {
throw new ResourceException(
"Failed to create or locate a registry, port=" + port,
nested);
}
}
_factory = new RMIInvokerFactoryImpl(_authenticator, this, listener);
try {
UnicastRemoteObject.exportObject(_factory, port);
} catch (RemoteException exception) {
throw new ResourceException("Failed to export object", exception);
}
RegistryHelper.bind(_factory, _uri, registry);
_registry = registry;
}