本文整理了Java中java.rmi.Naming
类的一些代码示例,展示了Naming
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Naming
类的具体详情如下:
包路径:java.rmi.Naming
类名称:Naming
暂无
代码示例来源:origin: spring-projects/spring-framework
stub = Naming.lookup(getServiceUrl());
代码示例来源:origin: decaywood/XueQiuSuperSpider
public void asRMISlave() {
try {
//创建并导出接受指定port请求的本地主机上的Registry实例。
String[] address = GlobalSystemConfigLoader.getRMIConfig("slave_rcv_ip").split(":");
String slaveIP = address[0].trim();
int port = Integer.parseInt(address[1].trim());
System.setProperty("java.rmi.server.hostname", slaveIP);
LocateRegistry.createRegistry(port);
/**
* Naming 类提供在对象注册表中存储和获得远程对远程对象引用的方法
* Naming 类的每个方法都可将某个名称作为其一个参数
* 该名称是使用以下形式的 URL 格式(没有 scheme 组件)的 java.lang.String:
* rmi://host:port/name
* host:注册表所在的主机(远程或本地),省略则默认为本地主机
* port:是注册表接受调用的端口号,省略则默认为1099,RMI注册表registry使用的著名端口
* name:是未经注册表解释的简单字符串
*/
Naming.rebind(getInvokeURL(slaveIP, port), this);
System.out.println("RMI Slave 启动成功" + " URL: " + getInvokeURL(slaveIP, port));
}catch(Exception e){
e.printStackTrace();
System.out.println("RMI Slave 创建失败");
}
}
代码示例来源:origin: apache/geode
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);
}
}
}
代码示例来源:origin: apache/geode
.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();
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
connection = new RMIConnection(((RMIServerSessionManager)Naming.lookup(url)).createRemoteSessionController());
} catch (Exception exception) {
throw ValidationException.invalidValueForProperty(url, PersistenceUnitProperties.REMOTE_URL, exception);
Naming.unbind(serverName);
} catch (Exception exception) {
Naming.rebind(serverName, manager);
} catch (Exception exception) {
ValidationException.invalidValueForProperty(serverName, PersistenceUnitProperties.REMOTE_SERVER_NAME, exception);
代码示例来源:origin: net.sf.ehcache/ehcache
String url = rmiCachePeer.getUrl();
try {
Naming.unbind(url);
} catch (NotBoundException e) {
LOG.warn(url + " not bound therefore not unbinding.");
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
Naming.rebind(name, engine);
System.out.println("RemoteEngine bound in RMI registry");
} catch (RemoteException ex) {
+ "...");
java.rmi.registry.LocateRegistry.createRegistry(port);
Naming.bind(name, engine);
System.out.println("RemoteEngine bound in RMI registry");
代码示例来源:origin: stackoverflow.com
Naming.bind(bindLocation, Hello);
System.out.println("Addition Server is ready at:" + bindLocation);
} catch (RemoteException e) {
代码示例来源:origin: stackoverflow.com
public interface Server extends java.rmi.Remote {
void doIt () throws java.rmi.RemoteException;
}
public class ServerImpl extends java.rmi.server.UnicastRemoteObject implements Server {
public ServerImpl() throws java.rmi.RemoteException {
super();
}
public void doIt () {
System.out.println ("Starting in " + Thread.currentThread().getName());
try { Thread.sleep(10000); } catch(InterruptedException t) {}
System.out.println ("Stopping in " + Thread.currentThread().getName());
}
public static void main (String[] argv) throws Exception {
java.rmi.registry.LocateRegistry.createRegistry(1099);
java.rmi.Naming.rebind ("//localhost/Server", new ServerImpl ());
}
}
public class Client {
public static void main(String[] argv) throws Exception {
((Server) java.rmi.Naming.lookup("Server")).doIt();
}
}
代码示例来源:origin: io.snappydata/gemfire-hydra-tests
/**
* Cleans up after this test by unbinding the instance of
* <code>RemoteBlockingQueue</code> that was initialized in {@link
* #setUp}.
*/
public void tearDown2() throws Exception {
Naming.unbind(this.queueURL);
}
代码示例来源:origin: Waikato/weka-trunk
Naming.rebind(name, engine);
System.out.println("RemoteEngine bound in RMI registry");
} catch (RemoteException ex) {
+ "...");
java.rmi.registry.LocateRegistry.createRegistry(port);
Naming.bind(name, engine);
System.out.println("RemoteEngine bound in RMI registry");
代码示例来源:origin: io.snappydata/gemfire-hydra-tests
/**
* Initializes this test by binding an instance of
* <code>RemoteBlockingQueueImpl</code> into the RMI registry hosted
* in Hydra's master controller VM.
*/
public void setUp() throws Exception {
String queueName = this.getUniqueName();
Host host = Host.getHost(0);
this.queueURL = RmiRegistryHelper.getMasterRegistryURL() + queueName;
RemoteBlockingQueue queue =
new RemoteBlockingQueueImpl(QUEUE_CAPACITY);
DistributedTestCase.getLogWriter().info("Binding queue named \"" + this.queueURL
+ "\"");
Naming.bind(this.queueURL, queue);
}
代码示例来源:origin: decaywood/XueQiuSuperSpider
protected Object getRMIProxy() throws RemoteException, NotBoundException, MalformedURLException {
Entry<String, Integer> entry = slaveChooser.chooseSlave();
String slaveIP = entry.getKey();
int port = entry.getValue();
System.out.println(getInvokeURL(slaveIP, port));
return Naming.lookup(getInvokeURL(slaveIP, port));
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* Bind a cache peer
*
* @param rmiCachePeer
*/
protected void bind(String peerName, RMICachePeer rmiCachePeer) throws Exception {
Naming.rebind(peerName, rmiCachePeer);
}
代码示例来源:origin: io.snappydata/dunit
public static void main(String[] args) throws Throwable {
try {
int namingPort = Integer.getInteger(DUnitLauncher.RMI_PORT_PARAM).intValue();
int vmNum = Integer.getInteger(DUnitLauncher.VM_NUM_PARAM).intValue();
int pid = NativeCalls.getInstance().getProcessId();
logger.info("VM" + vmNum + " is launching" + (pid > 0 ? " with PID " + pid : ""));
DUnitLauncher.MasterRemote holder = (DUnitLauncher.MasterRemote) Naming.lookup(
"//localhost:" + namingPort + "/" + DUnitLauncher.MASTER_PARAM);
DUnitLauncher.init(holder);
DUnitLauncher.locatorPort = holder.getLocatorPort();
Naming.rebind("//localhost:" + namingPort + "/vm" + vmNum, new RemoteDUnitVM());
holder.signalVMReady();
//This loop is here so this VM will die even if the master is mean killed.
while (true) {
holder.ping();
Thread.sleep(1000);
}
} catch (Throwable t) {
t.printStackTrace();
System.exit(1);
}
}
}
代码示例来源:origin: org.apache.oodt/cas-filemgr
public void stopServer(int port) throws RemoteException {
try {
Naming.unbind("rmi://localhost:" + port + "/RmiDatabaseServer");
UnicastRemoteObject.unexportObject(reg,true);
} catch (Exception e) {
LOG.log(Level.SEVERE, e.getMessage());
throw new RemoteException(
"Unable to unbind Database Server: reason: "
+ e.getMessage());
}
}
代码示例来源:origin: io.snappydata/gemfire-hydra-tests
public static void main(String[] args) throws Throwable {
try {
int namingPort = Integer.getInteger(DUnitLauncher.RMI_PORT_PARAM).intValue();
int vmNum = Integer.getInteger(DUnitLauncher.VM_NUM_PARAM).intValue();
LogWriter log = Log.createLogWriter("dunit-vm-" + vmNum, DUnitLauncher.LOG_LEVEL);
System.out.println("VM" + vmNum + " is launching");
DUnitLauncher.initSystemProperties(log);
MasterRemote holder = (MasterRemote) Naming.lookup("//localhost:" + namingPort + "/" + DUnitLauncher.MASTER_PARAM);
RemoteTestModule.Master = new FakeMaster();
DUnitLauncher.locatorPort = holder.getLocatorPort();
Naming.bind("//localhost:" + namingPort + "/vm" + vmNum, new FakeRemoteTestModule(log));
holder.signalVMReady();
//This loop is here so this VM will die even if the master is mean killed.
while(true) {
holder.ping();
Thread.sleep(1000);
}
} catch (Throwable t) {
t.printStackTrace();
System.exit(1);
}
}
代码示例来源:origin: org.springframework/spring-context
stub = Naming.lookup(getServiceUrl());
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache
/**
* Bind a cache peer
*
* @param rmiCachePeer
*/
protected void bind(String peerName, RMICachePeer rmiCachePeer) throws Exception {
Naming.rebind(peerName, rmiCachePeer);
}
代码示例来源:origin: apache/oodt
public void stopServer(int port) throws RemoteException {
try {
Naming.unbind("rmi://localhost:" + port + "/RmiDatabaseServer");
UnicastRemoteObject.unexportObject(reg,true);
} catch (Exception e) {
LOG.log(Level.SEVERE, e.getMessage());
throw new RemoteException(
"Unable to unbind Database Server: reason: "
+ e.getMessage());
}
}
内容来源于网络,如有侵权,请联系作者删除!