java.rmi.Naming.rebind()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(385)

本文整理了Java中java.rmi.Naming.rebind()方法的一些代码示例,展示了Naming.rebind()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Naming.rebind()方法的具体详情如下:
包路径:java.rmi.Naming
类名称:Naming
方法名:rebind

Naming.rebind介绍

暂无

代码示例

代码示例来源: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

final RemoteDUnitVM dunitVM = new RemoteDUnitVM();
final String name = "//localhost:" + namingPort + "/vm" + vmNum;
Naming.rebind(name, dunitVM);
JUnit4DistributedTestCase.initializeBlackboard();
holder.signalVMReady();

代码示例来源: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: 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: net.sf.ehcache.internal/ehcache-core

/**
 * Bind a cache peer
 *
 * @param rmiCachePeer
 */
protected void bind(String peerName, RMICachePeer rmiCachePeer) throws Exception {
  Naming.rebind(peerName, rmiCachePeer);
}

代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache

/**
 * Bind a cache peer
 *
 * @param rmiCachePeer
 */
protected void bind(String peerName, RMICachePeer rmiCachePeer) throws Exception {
  Naming.rebind(peerName, rmiCachePeer);
}

代码示例来源:origin: org.graphstream/gs-core

public void bind(String name) {
  try {
    Naming.rebind(String.format("//localhost/%s", name), this);
  } catch (Exception e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: graphstream/gs-core

public void bind(String name) {
  try {
    Naming.rebind(String.format("//localhost/%s", name), this);
  } catch (Exception e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: graphstream/gs-core

public void bind(String name) {
  try {
    Naming.rebind(String.format("//localhost/%s", name), this);
  } catch (Exception e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: org.graphstream/gs-core

public void bind(String name) {
  try {
    Naming.rebind(String.format("//localhost/%s", name), this);
  } catch (Exception e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: org.apache.oodt/cas-filemgr

private void launchRmiServer(int port) throws RemoteException {
  try {
    reg = LocateRegistry.createRegistry(port);
    Naming.rebind("rmi://localhost:" + port + "/RmiDatabaseServer", this);
    System.out.println("RMI server created at rmi://localhost:" + port
        + "/RmiDatabaseServer");
  } catch (Exception e) {
    throw new RemoteException("Failed to create RMI Server : "
        + e.getMessage());
  }
  
}

代码示例来源:origin: apache/oodt

private void launchRmiServer(int port) throws RemoteException {
  try {
    reg = LocateRegistry.createRegistry(port);
    Naming.rebind("rmi://localhost:" + port + "/RmiDatabaseServer", this);
    System.out.println("RMI server created at rmi://localhost:" + port
        + "/RmiDatabaseServer");
  } catch (Exception e) {
    throw new RemoteException("Failed to create RMI Server : "
        + e.getMessage());
  }
  
}

代码示例来源:origin: JeffreyWei/PatternViaJava

public static void main(String[] args) {
    try {
      //both method
      Remote server = new ServerRemoteImpl();
      //ServerRemote server=new ServerRemoteImpl();
      //open local port
      java.rmi.registry.LocateRegistry.createRegistry(5099);
      Naming.rebind("//:5099/RemoteServer", server);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

代码示例来源:origin: com.github.rjolly/remote4j

public <T> void rebind(final String name, final T value) throws RemoteException, MalformedURLException {
  Naming.rebind(name, apply(value));
}

代码示例来源:origin: lucene/lucene

/** Exports a searcher for the index in args[0] named
 * "//localhost/Searchable". */
public static void main(String args[]) throws Exception {
 // create and install a security manager
 if (System.getSecurityManager() == null) {
  System.setSecurityManager(new RMISecurityManager());
 }
 
 Searchable local = new IndexSearcher(args[0]);
 RemoteSearchable impl = new RemoteSearchable(local);
  
 // bind the implementation to "Searchable"
 Naming.rebind("//localhost/Searchable", impl);
}

代码示例来源:origin: org.neo4j/neo4j-shell

/**
 * Binds an object to the RMI location defined by this instance.
 *
 * @param object the object to bind.
 * @throws RemoteException RMI error.
 */
public void bind( Remote object ) throws RemoteException
{
  this.registry = ensureRegistryCreated();
  try
  {
    Naming.rebind( toUrl(), object );
  }
  catch ( MalformedURLException e )
  {
    throw new RemoteException( "Malformed URL", e );
  }
}

代码示例来源:origin: emc-mongoose/mongoose

public static String create(final Service svc, final int port)
  throws URISyntaxException, MalformedURLException, SocketException, RemoteException {
 String svcUri = null;
 synchronized (SVC_MAP) {
  // ensureRmiUseFixedPort(port);
  ensureRmiRegistryIsAvailableAt(port);
  UnicastRemoteObject.exportObject(svc, port);
  final String svcName = svc.name();
  svcUri = getLocalSvcUri(svcName, port).toString();
  if (!SVC_MAP.containsKey(svcName + ":" + port)) {
   Naming.rebind(svcUri, svc);
   SVC_MAP.put(svcName + ":" + port, new WeakReference<>(svc));
  } else {
   throw new AssertionError("Service already registered");
  }
 }
 return svcUri;
}

代码示例来源:origin: percyliang/fig

public static void main(String[] args) {
  Options options = new Options();
  if(!new OptionsParser().register("main", options).parse(args)) return;

  try {
   RecordServer server = new RecordServer(options.rootPath);
   new CommandProcessor(server, options.baseTempDir,
     false, false).processCommandFiles(options.commandFiles);
   Naming.rebind("RecordServer/"+options.id, server);
  } catch(Throwable t) {
   t.printStackTrace();
  }
 }
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * INTERNAL:
 * Put the local command connection of this transport in the Registry and return it
 */
protected RemoteConnection createLocalConnectionInRegistry() {
  String fullURL = formatURLforRegistry(rcm.getServiceId().getURL(), rcm.getServiceId().getId());
  try {
    // Register the remote connection in RMI Registry naming service
    RMIRemoteCommandConnectionImpl remoteConnectionObject = new RMIRemoteCommandConnectionImpl(rcm);
    Object[] args = { fullURL };
    rcm.logDebug("register_local_connection_in_registry", args);
    Naming.rebind(fullURL, remoteConnectionObject);
    localConnection = new RMIRemoteConnection(remoteConnectionObject);
  } catch (Exception exception) {
    rcm.handleException(RemoteCommandManagerException.errorBindingConnection(fullURL, exception));
  }
  return localConnection;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * INTERNAL:
 * Put the local command connection of this transport in the Registry and return it
 */
protected RemoteConnection createLocalConnectionInRegistry() {
  String fullURL = formatURLforRegistry(rcm.getServiceId().getURL(), rcm.getServiceId().getId());
  try {
    // Register the remote connection in RMI Registry naming service
    RMIRemoteCommandConnectionImpl remoteConnectionObject = new RMIRemoteCommandConnectionImpl(rcm);
    Object[] args = { fullURL };
    rcm.logDebug("register_local_connection_in_registry", args);
    Naming.rebind(fullURL, remoteConnectionObject);
    localConnection = new RMIRemoteConnection(remoteConnectionObject);
  } catch (Exception exception) {
    rcm.handleException(RemoteCommandManagerException.errorBindingConnection(fullURL, exception));
  }
  return localConnection;
}

相关文章