[有什么]与java.rmi.Naming
java.rmi.registry.LocateRegistry
不同之处在于,将字段解析为 URL,而 将 分析为“要与远程引用关联的名称”。该调用假定注册表位于默认端口的本地主机上,而 允许您指定要使用的注册表。name
Naming.rebind()
Registry.rebind()
LocateRegistry.getRegistry()
Naming.rebind()
在Java 1.6下,将解析为URL并使用注册表的主机/端口进行调用。这要求.Naming.rebind()
name
Naming.getRegistry()
LocateRegistry.getRegistry(host, port)
public static void rebind(String name, Remote obj) throws RemoteException, MalformedURLException
ParsedNamingURL parsed = parseURL(name);
Registry registry = getRegistry(parsed);
if (obj == null)
throw new NullPointerException("cannot bind to null");
registry.rebind(parsed.name, obj);
}
...
private static Registry getRegistry(ParsedNamingURL parsed) throws RemoteException {
return LocateRegistry.getRegistry(parsed.host, parsed.port);
}