當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。