本文整理匯總了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();
}
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
}
示例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);
}
}
示例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();
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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]);
}
}
示例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);
}
}
示例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]);
}
}
示例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);
}
}