zoukankan      html  css  js  c++  java
  • 【java】Naming.bind和Registry.bind区别

    1. Naming类和Registry类均在java.rmi包
    2. Naming类通过解析URI绑定远程对象,将URI拆分成主机、端口和远程对象名称,使用的仍是Registry类。

    java
    public static Remote lookup(String name)
    throws NotBoundException,
    java.net.MalformedURLException,
    RemoteException
    {
    ParsedNamingURL parsed = parseURL(name);
    Registry registry = getRegistry(parsed);

        if (parsed.name == null)
            return registry;
        return registry.lookup(parsed.name);
    }
    

    public static void bind(String name, Remote obj)
    throws AlreadyBoundException,
    java.net.MalformedURLException,
    RemoteException
    {
    ParsedNamingURL parsed = parseURL(name);
    Registry registry = getRegistry(parsed);

        if (obj == null)
            throw new NullPointerException("cannot bind to null");
    
        registry.bind(parsed.name, obj);
    }
    
    private static Registry getRegistry(ParsedNamingURL parsed)
        throws RemoteException
    {
        return LocateRegistry.getRegistry(parsed.host, parsed.port);
    }
    
  • 相关阅读:
    Linux设备管理(一):kobject, kset, ktype分析
    Keepalived高可用集群
    Nginx反向代理与负载均衡
    LNMP环境应用实践
    HTTP协议
    Nginx详解
    MySQL进阶
    MySQL安装与基本使用
    Jumpserver跳板机
    PXE自动化装机
  • 原文地址:https://www.cnblogs.com/lzxianren/p/rmi-naming.html
Copyright © 2011-2022 走看看