当前位置: 首页>>代码示例>>Java>>正文


Java Naming.lookup方法代码示例

本文整理汇总了Java中java.rmi.Naming.lookup方法的典型用法代码示例。如果您正苦于以下问题:Java Naming.lookup方法的具体用法?Java Naming.lookup怎么用?Java Naming.lookup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.rmi.Naming的用法示例。


在下文中一共展示了Naming.lookup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.rmi.Naming; //导入方法依赖的package包/类
public static void main(String[] args) {
    if (args.length == 0) {
        System.err.println("usage: RegistryInspector [registry url]");
        System.exit(-1);
    }

    String registry = args[0];
    try {
        String[] names = Naming.list(registry);
        for (String name : names) {
            Remote remoteObject = Naming.lookup(name);
            if (remoteObject != null) {
                System.out.println("name[" + name + "] class=" + remoteObject.getClass().getCanonicalName());
            } else {
                System.out.println("name[" + name + "] is null.");
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:22,代码来源:RegistryInspector.java

示例2: connectRemote

import java.rmi.Naming; //导入方法依赖的package包/类
private MplsnmsRmiServiceAccessPoint connectRemote(CoreConfiguration config) throws NotBoundException,
        MalformedURLException, RemoteException {
    if (this.ap != null) {
        try {
            this.ap.getServiceFacade();
            return this.ap;
        } catch (RemoteException e) {
            log.warn("got error from existing remote [MplsnmsRmiServiceAccessPoint].", e);
            this.ap = null;
        }
    }
    MplsnmsRmiServiceAccessPoint newAccessPoint = (MplsnmsRmiServiceAccessPoint) Naming.lookup(config.getDbServerUrl());
    if (newAccessPoint == null) {
        throw new IllegalStateException("inventory server not found on " + config.getDbServerUrl());
    }
    this.ap = newAccessPoint;
    registTriggers();
    return ap;
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:20,代码来源:DefaultNaefBridge.java

示例3: SKAdminShell

import java.rmi.Naming; //导入方法依赖的package包/类
public SKAdminShell(SKGridConfiguration gc, InputStream in, PrintStream out, PrintStream err, String server, int port) throws NotBoundException, KeeperException, IOException {
	this.gc = gc;
	zkConfig = gc.getClientDHTConfiguration().getZKConfig();
	zk = new ZooKeeperExtended(zkConfig, zkTimeout, this);
       this.in = new BufferedReader(new InputStreamReader(in));
       this.out = out;
       this.err = err;
       rmc = (RingMasterControl)Naming.lookup("rmi://"+ server +":"+ port +"/"+ RingMasterControl.getRegistryName(gc));
       sw = new SimpleStopwatch();
       rings = ImmutableList.of();
       
	com.ms.silverking.cloud.dht.meta.MetaClient	dhtMC;
	com.ms.silverking.cloud.dht.meta.MetaPaths  dhtMP;
    long            	latestConfigVersion;
    DHTConfiguration	dhtConfig;

    dhtMC = new com.ms.silverking.cloud.dht.meta.MetaClient(gc);
    dhtMP = dhtMC.getMetaPaths();
    latestConfigVersion = dhtMC.getZooKeeper().getLatestVersion(dhtMP.getInstanceConfigPath()); 
    dhtConfig = new DHTConfigurationZK(dhtMC).readFromZK(latestConfigVersion, null);
    curTargetZK = new DHTRingCurTargetZK(dhtMC, dhtConfig);
}
 
开发者ID:Morgan-Stanley,项目名称:SilverKing,代码行数:23,代码来源:SKAdminShell.java

示例4: actorOf

import java.rmi.Naming; //导入方法依赖的package包/类
/**
 * Create an instance of {@code actor} returning a {@link ActorRef reference}
 * to it using the given {@code mode} and a unique name inside the cluster.
 *
 * @param actor The type of actor that has to be created
 * @param mode The mode of the actor requested
 * @param name The name of the actor inside the cluster, must be unique
 *
 * @return A reference to the actor
 */
@Override
public ActorRef<? extends Message> actorOf(Class<? extends Actor> actor, ActorMode mode, String name) throws RemoteException {
    ActorRef<? extends Message> ref = null;
    switch (mode) {
    case LOCAL:
        ref = system.actorOf(actor, mode, name);
        synchronized(this) {
            updateRemoteActors(name, ref);
        }
        break;
    case REMOTE:
        String addr = name.split("/")[0];
        String memberName = (String)
            members.stream().filter(x -> x.startsWith(addr)).toArray()[0];
        try {
            Cluster remoteMember = (Cluster) Naming.lookup("rmi://" + memberName);
            ref = remoteMember.actorOf(actor, ActorMode.LOCAL, name);
        } catch (NotBoundException | MalformedURLException | RemoteException e) {
            e.printStackTrace();
        }
        break;
    }
    return ref;
}
 
开发者ID:codepr,项目名称:jas,代码行数:35,代码来源:ClusterImpl.java

示例5: main

import java.rmi.Naming; //导入方法依赖的package包/类
/**
 * @param args the command line arguments
 */
public static void main(String[] args) {        

    try {

        FileSearch fSearch = (FileSearch) Naming.lookup("rmi://localhost:1099/MasterIndex");
        
        FileServer fServer = new FileServerImpl();
        
        String clave = fSearch.registra("SergioGarciaPrado", fServer);
        System.out.println("Servidor local registrado con nombre: "+clave);
        
     } catch (Exception e) {
        System.err.println("<Cliente: Excepcion: "+e);
        e.printStackTrace();
     }
}
 
开发者ID:garciparedes,项目名称:PracticasSistemasDistribuidos,代码行数:20,代码来源:RMIP2PClientServer.java

示例6: main

import java.rmi.Naming; //导入方法依赖的package包/类
/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    Contador c = null;
    try {
        Caja caja = (Caja) Naming.lookup("rmi://localhost:1099/CajaRemota");

        c = (Contador) caja.lee();
        if (null != c) {
            System.out.println("valor de la caja: "+c.lee());
            caja.quita();
            System.out.println("Caja vaciada.");
        } else
            System.out.println("La caja estaba vacía.");
    } catch (Exception e) {
        e.printStackTrace(System.err);
    }
}
 
开发者ID:garciparedes,项目名称:PracticasSistemasDistribuidos,代码行数:20,代码来源:CajaClientRMIquita.java

示例7: Client

import java.rmi.Naming; //导入方法依赖的package包/类
public Client(String server) throws Exception {
	try {
		sampleCompany = (Company) Naming.lookup("//" + server + "/meganalysis");
	} catch (MalformedURLException malformedException) {
		System.err.println("Bad URL: " + malformedException);
	} catch (NotBoundException notBoundException) {
		System.err.println("Not Bound: " + notBoundException);
	} catch (RemoteException remoteException) {
		System.err.println("Remote Exception: " + remoteException);
	}
	
	demo();
}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:14,代码来源:Client.java

示例8: connect

import java.rmi.Naming; //导入方法依赖的package包/类
/**
 * NaEF へ RMI 接続を行う
 *
 * @return RMI AP
 */
public MplsnmsRmiServiceAccessPoint connect() {
    if (_ap != null) {
        // TODO naefへの再接続/DtoChangeListenerの再登録
        return _ap;
    }

    try {
        Logs.naef.info("connecting...");
        MplsnmsRmiServiceAccessPoint integratedAp = PasaranNaefService.getRmiServiceAccessPoint();
        if (integratedAp != null) {
            // naef integrated mode
            Logs.naef.info("connection successful. [INTEGRATED] mode");
            _ap = integratedAp;
        } else {
            // naef separate mode
            NotifierConfig conf = NotifierConfig.instance();
            String rmi = "rmi://" + conf.naefAddr() + ":" + conf.naefPort() + "/" + conf.naefServiceName();
            MplsnmsRmiServiceAccessPoint separateAp = (MplsnmsRmiServiceAccessPoint) Naming.lookup(rmi);
            _ap = separateAp;
            Logs.naef.info("connection successful. [SEPARATE] mode");
        }
    } catch (Exception e) {
        Logs.naef.error("connection failed", e);
        throw new IllegalStateException("naef 接続に失敗.");
    }
    return _ap;
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:33,代码来源:NaefRmiConnector.java

示例9: main

import java.rmi.Naming; //导入方法依赖的package包/类
public static void main(String[] args) throws Throwable {
  try {
    int namingPort = Integer.getInteger(DUnitLauncher.RMI_PORT_PARAM);
    int vmNum = Integer.getInteger(DUnitLauncher.VM_NUM_PARAM);
    String geodeVersion = System.getProperty(DUnitLauncher.VM_VERSION_PARAM);
    int pid = OSProcess.getId();
    logger.info("VM" + vmNum + " is launching" + (pid > 0 ? " with PID " + pid : ""));
    if (!VersionManager.isCurrentVersion(geodeVersion)) {
      logger.info("This VM is using Geode version {}", geodeVersion);
    }
    MasterRemote holder = (MasterRemote) Naming
        .lookup("//localhost:" + namingPort + "/" + DUnitLauncher.MASTER_PARAM);
    DUnitLauncher.init(holder);
    DUnitLauncher.locatorPort = holder.getLocatorPort();
    final RemoteDUnitVM dunitVM = new RemoteDUnitVM();
    final String name = "//localhost:" + namingPort + "/vm" + vmNum;
    Naming.rebind(name, dunitVM);
    JUnit4DistributedTestCase.initializeBlackboard();
    holder.signalVMReady();
    // This loop is here so this VM will die even if the master is mean killed.
    while (!stopMainLoop) {
      holder.ping();
      Thread.sleep(1000);
    }
  } catch (Throwable t) {
    t.printStackTrace();
    System.exit(1);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:30,代码来源:ChildVM.java

示例10: initialize

import java.rmi.Naming; //导入方法依赖的package包/类
private static synchronized void initialize() throws Exception {
  if (blackboard == null) {
    System.out.println(
        DUnitLauncher.RMI_PORT_PARAM + "=" + System.getProperty(DUnitLauncher.RMI_PORT_PARAM));
    int namingPort = Integer.getInteger(DUnitLauncher.RMI_PORT_PARAM).intValue();
    String name = "//localhost:" + namingPort + "/" + "InternalBlackboard";
    try {
      blackboard = (InternalBlackboard) Naming.lookup(name);
    } catch (NotBoundException e) {
      // create the master blackboard in this VM
      blackboard = new InternalBlackboardImpl();
      Naming.bind(name, blackboard);
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:16,代码来源:InternalBlackboardImpl.java

示例11: initialize

import java.rmi.Naming; //导入方法依赖的package包/类
private static synchronized void initialize() throws Exception {
  if (blackboard == null) {
    System.out.println(
        DUnitLauncher.RMI_PORT_PARAM + "=" + System.getProperty(DUnitLauncher.RMI_PORT_PARAM));
    int namingPort = Integer.getInteger(DUnitLauncher.RMI_PORT_PARAM).intValue();
    String name = "//localhost:" + namingPort + "/" + "DistributedLockBlackboard";
    try {
      blackboard = (DistributedLockBlackboard) Naming.lookup(name);
    } catch (NotBoundException e) {
      // create the master blackboard in this VM
      blackboard = new DistributedLockBlackboardImpl();
      Naming.bind(name, blackboard);
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:16,代码来源:DistributedLockBlackboardImpl.java

示例12: main

import java.rmi.Naming; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    String[] names = {
        "fairly:simple", "somewhat:more/complicated",
        "multiple:colons:in:name"
    };

    Registry reg = TestLibrary.createRegistryOnUnusedPort();
    int port = TestLibrary.getRegistryPort(reg);

    for (int i = 0; i < names.length; i++) {
        reg.rebind(names[i], reg);
        Naming.lookup("rmi://localhost:" + port + "/" + names[i]);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:LookupNameWithColon.java

示例13: main

import java.rmi.Naming; //导入方法依赖的package包/类
public static void main(String args[]) {
    UnderscoreHost t = null;
    try {
        HostVerifyingSocketFactory hvf = new HostVerifyingSocketFactory();
        RMISocketFactory.setSocketFactory(hvf);
        Registry r = TestLibrary.createRegistryOnUnusedPort();
        int port = TestLibrary.getRegistryPort(r);
        t = new UnderscoreHost();
        r.rebind(NAME, t);
        Naming.lookup("rmi://" + HOSTNAME +
                      ":" + port + "/" + NAME);
        /*
         * This test is coded to pass whether java.net.URI obeys
         * RFC 2396 or RFC 3986 (see 5085902, 6394131, etc.).
         *
         * If java.net.URI obeys RFC 3986, so host names may
         * contain underscores, then the Naming.lookup invocation
         * should succeed-- but the host actually connected to
         * must equal HOSTNAME.
         */
        if (!hvf.host.equals(HOSTNAME)) {
            throw new RuntimeException(
                "java.rmi.Naming Parsing error:" +
                hvf.host + ":" + HOSTNAME);
        }
    } catch (MalformedURLException e) {
        /*
         * If java.net.URI obeys RFC 2396, so host names must not
         * contain underscores, then the Naming.lookup invocation
         * should throw MalformedURLException-- so this is OK.
         */
    } catch (IOException ioe) {
        TestLibrary.bomb(ioe);
    } catch (java.rmi.NotBoundException nbe) {
        TestLibrary.bomb(nbe);
    } finally {
        TestLibrary.unexport(t);
    }

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:41,代码来源:UnderscoreHost.java

示例14: main

import java.rmi.Naming; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    String[] names = {
        "fairly:simple", "somewhat:more/complicated",
        "multiple:colons:in:name"
    };

    Registry reg = TestLibrary.createRegistryOnEphemeralPort();
    int port = TestLibrary.getRegistryPort(reg);

    for (int i = 0; i < names.length; i++) {
        reg.rebind(names[i], reg);
        Naming.lookup("rmi://localhost:" + port + "/" + names[i]);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:LookupNameWithColon.java

示例15: main

import java.rmi.Naming; //导入方法依赖的package包/类
public static void main(String args[]) {
    UnderscoreHost t = null;
    try {
        HostVerifyingSocketFactory hvf = new HostVerifyingSocketFactory();
        RMISocketFactory.setSocketFactory(hvf);
        Registry r = TestLibrary.createRegistryOnEphemeralPort();
        int port = TestLibrary.getRegistryPort(r);
        t = new UnderscoreHost();
        r.rebind(NAME, t);
        Naming.lookup("rmi://" + HOSTNAME +
                      ":" + port + "/" + NAME);
        /*
         * This test is coded to pass whether java.net.URI obeys
         * RFC 2396 or RFC 3986 (see 5085902, 6394131, etc.).
         *
         * If java.net.URI obeys RFC 3986, so host names may
         * contain underscores, then the Naming.lookup invocation
         * should succeed-- but the host actually connected to
         * must equal HOSTNAME.
         */
        if (!hvf.host.equals(HOSTNAME)) {
            throw new RuntimeException(
                "java.rmi.Naming Parsing error:" +
                hvf.host + ":" + HOSTNAME);
        }
    } catch (MalformedURLException e) {
        /*
         * If java.net.URI obeys RFC 2396, so host names must not
         * contain underscores, then the Naming.lookup invocation
         * should throw MalformedURLException-- so this is OK.
         */
    } catch (IOException ioe) {
        TestLibrary.bomb(ioe);
    } catch (java.rmi.NotBoundException nbe) {
        TestLibrary.bomb(nbe);
    } finally {
        TestLibrary.unexport(t);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:UnderscoreHost.java


注:本文中的java.rmi.Naming.lookup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。