@Test public void find_rmi_clients() throws Exception { for (int ii = 0; ii < 4; ii++) { generate_port_spawn(30); ClientListener cl = new ClientListener(); ScanListener sl = new ScanListener(); int before[] = generate_random_ports(1, 6, m_pmin - 10, m_pmin - 1); int after[] = generate_random_ports(1, 6, m_pmax + 1, m_pmax + 10); int inside[] = generate_random_ports(3, 15, m_pmin, m_pmax); int insidemin = -1; int insidemax = -1; int insidecnt = 0; Set<Integer> f = new HashSet<>(); for (int i = 0; i < before.length; i++) { if (i % 3 == 0) { @SuppressWarnings("unused") RandomService rs = new RandomService(before[i]); } else if (i % 3 == 1) { RmiServerPublisher.publish_service(RIntf.class, new RImpl(), before[i]); } else { RmiServerPublisher.publish_service(RIntf2.class, new RImpl2(), before[i]); } } for (int i = 0; i < after.length; i++) { if (i % 3 == 0) { @SuppressWarnings("unused") RandomService rs = new RandomService(after[i]); } else if (i % 3 == 1) { RmiServerPublisher.publish_service(RIntf.class, new RImpl(), after[i]); } else { RmiServerPublisher.publish_service(RIntf2.class, new RImpl2(), after[i]); } } for (int i = 0; i < inside.length; i++) { if (i % 3 == 0) { @SuppressWarnings("unused") RandomService rs = new RandomService(inside[i]); } else if (i % 3 == 1) { if (insidecnt == 0) { insidemin = inside[i]; insidemax = inside[i]; } else { if (insidemin > inside[i]) { insidemin = inside[i]; } if (insidemax > inside[i]) { insidemax = inside[i]; } } insidecnt++; RmiServerPublisher.publish_service(RIntf.class, new RImpl(), inside[i]); f.add(new Integer(inside[i])); } else { RmiServerPublisher.publish_service(RIntf2.class, new RImpl2(), inside[i]); } } RmiClientDiscovery.find_rmi_client("localhost", m_pmin, m_pmax, RIntf.class, cl, sl); assertEquals(insidecnt, cl.m_ports.length); assertEquals(m_pmin, sl.m_min); assertEquals(m_pmax, sl.m_max); for (int i = 0; i < cl.m_ports.length; i++) { assertTrue(f.contains(new Integer(cl.m_ports[i]))); } RmiServerPublisher.shutdown_all(); } }
public static <T> T find_rmi_client(String host, int port, Class<T> iface) { try { Client c = new Client(host, port); return iface.cast(c.lookup(iface)); } catch (Exception e) { } return null; }
RmiClientDiscovery { public static <T> T find_rmi_client(String host, int port, Class<T> iface) { try { Client c = new Client(host, port); return iface.cast(c.lookup(iface)); } catch (Exception e) { } return null; } }
RmiClientDiscovery { public static <T> T find_rmi_client(String host, int port, Class<T> iface) { try { Client c = new Client(host, port); return iface.cast(c.lookup(iface)); } catch (Exception e) { } return null; }  }
RmiClientDiscovery { public static <T> T find_rmi_client(String host, int port, Class<T> iface) { try { Client c = new Client(host, port); return iface.cast(c.lookup(iface)); } catch (Exception e) { } return null; }  static void find_open_ports(String host, int min_port, int max_port,
			PortFoundListener listener, PortScanListener scan_listener); static T find_rmi_client(String host, int port,
			Class<T> iface); static void find_rmi_client(final String host, int min_port,
			int max_port, final Class<?> iface,
			final ClientFoundListener listener,
			PortScanListener scan_listener); static void find_rmi_client(String host, Class<?> iface,
			ClientFoundListener listener, PortScanListener scan_listener); }
RmiClientDiscovery { public static <T> T find_rmi_client(String host, int port, Class<T> iface) { try { Client c = new Client(host, port); return iface.cast(c.lookup(iface)); } catch (Exception e) { } return null; }  static void find_open_ports(String host, int min_port, int max_port,
			PortFoundListener listener, PortScanListener scan_listener); static T find_rmi_client(String host, int port,
			Class<T> iface); static void find_rmi_client(final String host, int min_port,
			int max_port, final Class<?> iface,
			final ClientFoundListener listener,
			PortScanListener scan_listener); static void find_rmi_client(String host, Class<?> iface,
			ClientFoundListener listener, PortScanListener scan_listener);  }