Java Code Examples for java.rmi.Naming#rebind()
The following examples show how to use
java.rmi.Naming#rebind() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GumballMachineTestDrive.java From head-first-design-patterns-Java with MIT License | 6 votes |
public static void main(String[] args) { GumballMachineRemote gumballMachine = null; int count; if (args.length < 2) { System.out.println("GumballMachine <name> <inventory>"); System.exit(1); } try { count = Integer.parseInt(args[1]); gumballMachine = new GumballMachine(args[0], count); Naming.rebind("//" + args[0] + "/gumballmachine", gumballMachine); } catch (Exception e) { e.printStackTrace(); } }
Example 2
Source File: NumberCruncherServer.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public static void main(String[] args) { if(args.length != 1) usage("Wrong number of arguments."); NumberCruncherServer ncs; PropertyConfigurator.configure(args[0]); try { ncs = new NumberCruncherServer(); Naming.rebind("Factor", ncs); logger.info("NumberCruncherServer bound and ready to serve."); } catch(Exception e) { logger.error("Could not bind NumberCruncherServer.", e); return; } NumberCruncherClient.loop(ncs); }
Example 3
Source File: RemoteTrainerImpl.java From EasySRL with Apache License 2.0 | 5 votes |
public static void main(final String args[]) throws RemoteException, MalformedURLException, UnknownHostException { final String hostName = InetAddress.getLocalHost().getHostName(); System.out.println("Using server: " + hostName); System.setProperty("java.rmi.server.hostname", hostName); LocateRegistry.createRegistry(1099); final RemoteTrainerImpl trainer = new RemoteTrainerImpl(); Naming.rebind("RemoteTrainer", trainer); }
Example 4
Source File: AbstractRemoteService.java From XueQiuSuperSpider with MIT License | 5 votes |
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 创建失败"); } }
Example 5
Source File: RmiCacheServer.java From oodt with Apache License 2.0 | 5 votes |
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()); } }
Example 6
Source File: Server.java From PatternViaJava with Apache License 2.0 | 5 votes |
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(); } }