public ExampleRemoteClient() { try { rd = (RemoteDispatcher) Naming.lookup(RMI_URL); } catch (NotBoundException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (RemoteException e) { e.printStackTrace(); } }
static RemoteConnectionSet getSharedObject() { RemoteConnectionSet remoteConnectionSet = null; try { Registry registry = LocateRegistry.getRegistry(); remoteConnectionSet = (RemoteConnectionSet) registry.lookup(NAME); } catch (RemoteException e) { //e.printStackTrace(); remoteConnectionSet = new ConnectionSet(); } catch (NotBoundException e) { e.printStackTrace(); } return remoteConnectionSet; } }
public void cleanup() { try { Registry registry = LocateRegistry.getRegistry(port); try { registry.unbind(name); } catch (NotBoundException e) { e.printStackTrace(); } UnicastRemoteObject.unexportObject(shipping, true); } catch (Exception e) { } }
public void cleanup() { try { Registry registry = LocateRegistry.getRegistry(port); try { registry.unbind(name); } catch (NotBoundException e) { e.printStackTrace(); } UnicastRemoteObject.unexportObject(shipping, true); } catch (Exception e) { } }
public void test() { try { // 获取服务 RMIService server = (RMIService) this.getRegistry().lookup("test"); // 调用远程方法 String result = server.find("hhh"); System.out.println("调用结果:" + result); } catch (AccessException e) { e.printStackTrace(); } catch (RemoteException e) { e.printStackTrace(); } catch (NotBoundException e) { e.printStackTrace(); } } }
} catch (NotBoundException nbe2) { System.err.println("First attempt to connect to Java application failed"); nbe1.printStackTrace(); System.err.println("Second attempt to connect to Java application failed"); nbe2.printStackTrace(); return; nbe1.printStackTrace(); System.err.println("Interrupted while waiting to retry connection to Java application"); ie.printStackTrace();
} catch (NotBoundException nbe2) { System.err.println("First attempt to connect to Java application failed"); nbe1.printStackTrace(); System.err.println("Second attempt to connect to Java application failed"); nbe2.printStackTrace(); return; nbe1.printStackTrace(); System.err.println("Interrupted while waiting to retry connection to Java application"); ie.printStackTrace();