Java Code Examples for java.rmi.registry.Registry#list()
The following examples show how to use
java.rmi.registry.Registry#list() .
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: TestLibrary.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Helper method to determine if registry has started * * @param port The port number to check * @param msTimeout The amount of milliseconds to spend checking */ public static boolean checkIfRegistryRunning(int port, int msTimeout) { long stopTime = System.currentTimeMillis() + msTimeout; do { try { Registry r = LocateRegistry.getRegistry(port); String[] s = r.list(); // no exception. We're now happy that registry is running return true; } catch (RemoteException e) { // problem - not ready ? Try again try { Thread.sleep(500); } catch (InterruptedException ie) { // not expected } } } while (stopTime > System.currentTimeMillis()); return false; }
Example 2
Source File: TestLibrary.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Helper method to determine if registry has started * * @param port The port number to check * @param msTimeout The amount of milliseconds to spend checking */ public static boolean checkIfRegistryRunning(int port, int msTimeout) { long stopTime = System.currentTimeMillis() + msTimeout; do { try { Registry r = LocateRegistry.getRegistry(port); String[] s = r.list(); // no exception. We're now happy that registry is running return true; } catch (RemoteException e) { // problem - not ready ? Try again try { Thread.sleep(500); } catch (InterruptedException ie) { // not expected } } } while (stopTime > System.currentTimeMillis()); return false; }
Example 3
Source File: TestLibrary.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Helper method to determine if registry has started * * @param port The port number to check * @param msTimeout The amount of milliseconds to spend checking */ public static boolean checkIfRegistryRunning(int port, int msTimeout) { long stopTime = System.currentTimeMillis() + msTimeout; do { try { Registry r = LocateRegistry.getRegistry(port); String[] s = r.list(); // no exception. We're now happy that registry is running return true; } catch (RemoteException e) { // problem - not ready ? Try again try { Thread.sleep(500); } catch (InterruptedException ie) { // not expected } } } while (stopTime > System.currentTimeMillis()); return false; }
Example 4
Source File: TestLibrary.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Helper method to determine if registry has started * * @param port The port number to check * @param msTimeout The amount of milliseconds to spend checking */ public static boolean checkIfRegistryRunning(int port, int msTimeout) { final long POLLTIME_MS = 100L; long stopTime = computeDeadline(System.currentTimeMillis(), msTimeout); do { try { Registry r = LocateRegistry.getRegistry(port); String[] s = r.list(); // no exception. We're now happy that registry is running return true; } catch (RemoteException e) { // problem - not ready ? Try again try { Thread.sleep(POLLTIME_MS); } catch (InterruptedException ie) { // not expected } } } while (System.currentTimeMillis() < stopTime); return false; }
Example 5
Source File: TestLibrary.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Helper method to determine if registry has started * * @param port The port number to check * @param msTimeout The amount of milliseconds to spend checking */ public static boolean checkIfRegistryRunning(int port, int msTimeout) { long stopTime = System.currentTimeMillis() + msTimeout; do { try { Registry r = LocateRegistry.getRegistry(port); String[] s = r.list(); // no exception. We're now happy that registry is running return true; } catch (RemoteException e) { // problem - not ready ? Try again try { Thread.sleep(500); } catch (InterruptedException ie) { // not expected } } } while (stopTime > System.currentTimeMillis()); return false; }
Example 6
Source File: TestLibrary.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Helper method to determine if registry has started * * @param port The port number to check * @param msTimeout The amount of milliseconds to spend checking */ public static boolean checkIfRegistryRunning(int port, int msTimeout) { long stopTime = System.currentTimeMillis() + msTimeout; do { try { Registry r = LocateRegistry.getRegistry(port); String[] s = r.list(); // no exception. We're now happy that registry is running return true; } catch (RemoteException e) { // problem - not ready ? Try again try { Thread.sleep(500); } catch (InterruptedException ie) { // not expected } } } while (stopTime > System.currentTimeMillis()); return false; }
Example 7
Source File: JMXStartStopTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void testConnect(int port, int rmiPort) throws Exception { dbg_print("RmiRegistry lookup..."); dbg_print("Using port: " + port); dbg_print("Using rmi port: " + rmiPort); Registry registry = LocateRegistry.getRegistry(port); // "jmxrmi" String[] relist = registry.list(); for (int i = 0; i < relist.length; ++i) { dbg_print("Got registry: " + relist[i]); } String jmxUrlStr = (rmiPort != 0) ? String.format( "service:jmx:rmi://localhost:%d/jndi/rmi://localhost:%d/jmxrmi", rmiPort, port) : String.format( "service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi", port); JMXServiceURL url = new JMXServiceURL(jmxUrlStr); JMXConnector c = JMXConnectorFactory.connect(url, null); MBeanServerConnection conn = c.getMBeanServerConnection(); ObjectName pattern = new ObjectName("java.lang:type=Memory,*"); int count = listMBeans(conn,pattern,null); if (count == 0) throw new Exception("Expected at least one matching " + "MBean for " + pattern); }
Example 8
Source File: JMXStartStopTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void testConnect(int port, int rmiPort) throws Exception { dbg_print("RmiRegistry lookup..."); dbg_print("Using port: " + port); dbg_print("Using rmi port: " + rmiPort); Registry registry = LocateRegistry.getRegistry(port); // "jmxrmi" String[] relist = registry.list(); for (int i = 0; i < relist.length; ++i) { dbg_print("Got registry: " + relist[i]); } String jmxUrlStr = (rmiPort != 0) ? String.format( "service:jmx:rmi://localhost:%d/jndi/rmi://localhost:%d/jmxrmi", rmiPort, port) : String.format( "service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi", port); JMXServiceURL url = new JMXServiceURL(jmxUrlStr); JMXConnector c = JMXConnectorFactory.connect(url, null); MBeanServerConnection conn = c.getMBeanServerConnection(); ObjectName pattern = new ObjectName("java.lang:type=Memory,*"); int count = listMBeans(conn,pattern,null); if (count == 0) throw new Exception("Expected at least one matching " + "MBean for " + pattern); }
Example 9
Source File: JMXStartStopTest.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void testConnect(int port, int rmiPort) throws Exception { dbg_print("RmiRegistry lookup..."); dbg_print("Using port: " + port); dbg_print("Using rmi port: " + rmiPort); Registry registry = LocateRegistry.getRegistry(port); // "jmxrmi" String[] relist = registry.list(); for (int i = 0; i < relist.length; ++i) { dbg_print("Got registry: " + relist[i]); } String jmxUrlStr = (rmiPort != 0) ? String.format( "service:jmx:rmi://localhost:%d/jndi/rmi://localhost:%d/jmxrmi", rmiPort, port) : String.format( "service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi", port); JMXServiceURL url = new JMXServiceURL(jmxUrlStr); JMXConnector c = JMXConnectorFactory.connect(url, null); MBeanServerConnection conn = c.getMBeanServerConnection(); ObjectName pattern = new ObjectName("java.lang:type=Memory,*"); int count = listMBeans(conn,pattern,null); if (count == 0) throw new Exception("Expected at least one matching " + "MBean for " + pattern); }
Example 10
Source File: JMXStartStopTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void testConnect(int port, int rmiPort) throws Exception { dbg_print("RmiRegistry lookup..."); dbg_print("Using port: " + port); dbg_print("Using rmi port: " + rmiPort); Registry registry = LocateRegistry.getRegistry(port); // "jmxrmi" String[] relist = registry.list(); for (int i = 0; i < relist.length; ++i) { dbg_print("Got registry: " + relist[i]); } String jmxUrlStr = (rmiPort != 0) ? String.format( "service:jmx:rmi://localhost:%d/jndi/rmi://localhost:%d/jmxrmi", rmiPort, port) : String.format( "service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi", port); JMXServiceURL url = new JMXServiceURL(jmxUrlStr); JMXConnector c = JMXConnectorFactory.connect(url, null); MBeanServerConnection conn = c.getMBeanServerConnection(); ObjectName pattern = new ObjectName("java.lang:type=Memory,*"); int count = listMBeans(conn,pattern,null); if (count == 0) throw new Exception("Expected at least one matching " + "MBean for " + pattern); }
Example 11
Source File: PinClientSocketFactory.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { System.err.println("\nRegression test for bug 4486732\n"); Factory factoryImpl = new FactoryImpl(); Factory factoryStub = (Factory) UnicastRemoteObject.exportObject(factoryImpl, 0); for (int i = 0; i < SESSIONS; i++) { Session session = factoryStub.getSession(); session.ping(); } UnicastRemoteObject.unexportObject(factoryImpl, true); Registry registryImpl = TestLibrary.createRegistryOnEphemeralPort(); int port = TestLibrary.getRegistryPort(registryImpl); System.out.println("Registry listening on port " + port); CSF csf = new CSF(); Reference<CSF> registryRef = new WeakReference<CSF>(csf); Registry registryStub = LocateRegistry.getRegistry("", port, csf); csf = null; registryStub.list(); registryStub = null; UnicastRemoteObject.unexportObject(registryImpl, true); System.gc(); // allow connections to time out Thread.sleep(3 * Long.getLong("sun.rmi.transport.connectionTimeout", 15000)); System.gc(); if (CSF.deserializedInstances.size() != SESSIONS) { throw new Error("unexpected number of deserialized instances: " + CSF.deserializedInstances.size()); } int nonNullCount = 0; for (Reference<CSF> ref : CSF.deserializedInstances) { csf = ref.get(); if (csf != null) { System.err.println("non-null deserialized instance: " + csf); nonNullCount++; } } if (nonNullCount > 0) { throw new Error("TEST FAILED: " + nonNullCount + " non-null deserialized instances"); } csf = registryRef.get(); if (csf != null) { System.err.println("non-null registry instance: " + csf); throw new Error("TEST FAILED: non-null registry instance"); } System.err.println("TEST PASSED"); }
Example 12
Source File: PinClientSocketFactory.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { System.err.println("\nRegression test for bug 4486732\n"); Factory factoryImpl = new FactoryImpl(); Factory factoryStub = (Factory) UnicastRemoteObject.exportObject(factoryImpl, 0); for (int i = 0; i < SESSIONS; i++) { Session session = factoryStub.getSession(); session.ping(); } UnicastRemoteObject.unexportObject(factoryImpl, true); Registry registryImpl = LocateRegistry.createRegistry(PORT); CSF csf = new CSF(); Reference<CSF> registryRef = new WeakReference<CSF>(csf); Registry registryStub = LocateRegistry.getRegistry("", PORT, csf); csf = null; registryStub.list(); registryStub = null; UnicastRemoteObject.unexportObject(registryImpl, true); System.gc(); // allow connections to time out Thread.sleep(3 * Long.getLong("sun.rmi.transport.connectionTimeout", 15000)); System.gc(); if (CSF.deserializedInstances.size() != SESSIONS) { throw new Error("unexpected number of deserialized instances: " + CSF.deserializedInstances.size()); } int nonNullCount = 0; for (Reference<CSF> ref : CSF.deserializedInstances) { csf = ref.get(); if (csf != null) { System.err.println("non-null deserialized instance: " + csf); nonNullCount++; } } if (nonNullCount > 0) { throw new Error("TEST FAILED: " + nonNullCount + " non-null deserialized instances"); } csf = registryRef.get(); if (csf != null) { System.err.println("non-null registry instance: " + csf); throw new Error("TEST FAILED: non-null registry instance"); } System.err.println("TEST PASSED"); }
Example 13
Source File: PinClientSocketFactory.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { System.err.println("\nRegression test for bug 4486732\n"); Factory factoryImpl = new FactoryImpl(); Factory factoryStub = (Factory) UnicastRemoteObject.exportObject(factoryImpl, 0); for (int i = 0; i < SESSIONS; i++) { Session session = factoryStub.getSession(); session.ping(); } UnicastRemoteObject.unexportObject(factoryImpl, true); Registry registryImpl = LocateRegistry.createRegistry(PORT); CSF csf = new CSF(); Reference<CSF> registryRef = new WeakReference<CSF>(csf); Registry registryStub = LocateRegistry.getRegistry("", PORT, csf); csf = null; registryStub.list(); registryStub = null; UnicastRemoteObject.unexportObject(registryImpl, true); System.gc(); // allow connections to time out Thread.sleep(3 * Long.getLong("sun.rmi.transport.connectionTimeout", 15000)); System.gc(); if (CSF.deserializedInstances.size() != SESSIONS) { throw new Error("unexpected number of deserialized instances: " + CSF.deserializedInstances.size()); } int nonNullCount = 0; for (Reference<CSF> ref : CSF.deserializedInstances) { csf = ref.get(); if (csf != null) { System.err.println("non-null deserialized instance: " + csf); nonNullCount++; } } if (nonNullCount > 0) { throw new Error("TEST FAILED: " + nonNullCount + " non-null deserialized instances"); } csf = registryRef.get(); if (csf != null) { System.err.println("non-null registry instance: " + csf); throw new Error("TEST FAILED: non-null registry instance"); } System.err.println("TEST PASSED"); }
Example 14
Source File: PinClientSocketFactory.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { System.err.println("\nRegression test for bug 4486732\n"); Factory factoryImpl = new FactoryImpl(); Factory factoryStub = (Factory) UnicastRemoteObject.exportObject(factoryImpl, 0); for (int i = 0; i < SESSIONS; i++) { Session session = factoryStub.getSession(); session.ping(); } UnicastRemoteObject.unexportObject(factoryImpl, true); Registry registryImpl = TestLibrary.createRegistryOnEphemeralPort(); int port = TestLibrary.getRegistryPort(registryImpl); System.out.println("Registry listening on port " + port); CSF csf = new CSF(); Reference<CSF> registryRef = new WeakReference<CSF>(csf); Registry registryStub = LocateRegistry.getRegistry("", port, csf); csf = null; registryStub.list(); registryStub = null; UnicastRemoteObject.unexportObject(registryImpl, true); System.gc(); // allow connections to time out Thread.sleep(3 * Long.getLong("sun.rmi.transport.connectionTimeout", 15000)); System.gc(); if (CSF.deserializedInstances.size() != SESSIONS) { throw new Error("unexpected number of deserialized instances: " + CSF.deserializedInstances.size()); } int nonNullCount = 0; for (Reference<CSF> ref : CSF.deserializedInstances) { csf = ref.get(); if (csf != null) { System.err.println("non-null deserialized instance: " + csf); nonNullCount++; } } if (nonNullCount > 0) { throw new Error("TEST FAILED: " + nonNullCount + " non-null deserialized instances"); } csf = registryRef.get(); if (csf != null) { System.err.println("non-null registry instance: " + csf); throw new Error("TEST FAILED: non-null registry instance"); } System.err.println("TEST PASSED"); }
Example 15
Source File: PinClientSocketFactory.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { System.err.println("\nRegression test for bug 4486732\n"); Factory factoryImpl = new FactoryImpl(); Factory factoryStub = (Factory) UnicastRemoteObject.exportObject(factoryImpl, 0); for (int i = 0; i < SESSIONS; i++) { Session session = factoryStub.getSession(); session.ping(); } UnicastRemoteObject.unexportObject(factoryImpl, true); Registry registryImpl = LocateRegistry.createRegistry(PORT); CSF csf = new CSF(); Reference<CSF> registryRef = new WeakReference<CSF>(csf); Registry registryStub = LocateRegistry.getRegistry("", PORT, csf); csf = null; registryStub.list(); registryStub = null; UnicastRemoteObject.unexportObject(registryImpl, true); System.gc(); // allow connections to time out Thread.sleep(3 * Long.getLong("sun.rmi.transport.connectionTimeout", 15000)); System.gc(); if (CSF.deserializedInstances.size() != SESSIONS) { throw new Error("unexpected number of deserialized instances: " + CSF.deserializedInstances.size()); } int nonNullCount = 0; for (Reference<CSF> ref : CSF.deserializedInstances) { csf = ref.get(); if (csf != null) { System.err.println("non-null deserialized instance: " + csf); nonNullCount++; } } if (nonNullCount > 0) { throw new Error("TEST FAILED: " + nonNullCount + " non-null deserialized instances"); } csf = registryRef.get(); if (csf != null) { System.err.println("non-null registry instance: " + csf); throw new Error("TEST FAILED: non-null registry instance"); } System.err.println("TEST PASSED"); }
Example 16
Source File: PinClientSocketFactory.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { System.err.println("\nRegression test for bug 4486732\n"); Factory factoryImpl = new FactoryImpl(); Factory factoryStub = (Factory) UnicastRemoteObject.exportObject(factoryImpl, 0); for (int i = 0; i < SESSIONS; i++) { Session session = factoryStub.getSession(); session.ping(); } UnicastRemoteObject.unexportObject(factoryImpl, true); Registry registryImpl = TestLibrary.createRegistryOnEphemeralPort(); int port = TestLibrary.getRegistryPort(registryImpl); System.out.println("Registry listening on port " + port); CSF csf = new CSF(); Reference<CSF> registryRef = new WeakReference<CSF>(csf); Registry registryStub = LocateRegistry.getRegistry("", port, csf); csf = null; registryStub.list(); registryStub = null; UnicastRemoteObject.unexportObject(registryImpl, true); System.gc(); // allow connections to time out Thread.sleep(3 * Long.getLong("sun.rmi.transport.connectionTimeout", 15000)); System.gc(); if (CSF.deserializedInstances.size() != SESSIONS) { throw new Error("unexpected number of deserialized instances: " + CSF.deserializedInstances.size()); } int nonNullCount = 0; for (Reference<CSF> ref : CSF.deserializedInstances) { csf = ref.get(); if (csf != null) { System.err.println("non-null deserialized instance: " + csf); nonNullCount++; } } if (nonNullCount > 0) { throw new Error("TEST FAILED: " + nonNullCount + " non-null deserialized instances"); } csf = registryRef.get(); if (csf != null) { System.err.println("non-null registry instance: " + csf); throw new Error("TEST FAILED: non-null registry instance"); } System.err.println("TEST PASSED"); }
Example 17
Source File: RmiRegistryFactoryBean.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Test the given RMI registry, calling some operation on it to * check whether it is still active. * <p>Default implementation calls {@code Registry.list()}. * @param registry the RMI registry to test * @throws RemoteException if thrown by registry methods * @see java.rmi.registry.Registry#list() */ protected void testRegistry(Registry registry) throws RemoteException { registry.list(); }
Example 18
Source File: RmiServiceExporter.java From spring-analysis-note with MIT License | 2 votes |
/** * Test the given RMI registry, calling some operation on it to * check whether it is still active. * <p>Default implementation calls {@code Registry.list()}. * @param registry the RMI registry to test * @throws RemoteException if thrown by registry methods * @see java.rmi.registry.Registry#list() */ protected void testRegistry(Registry registry) throws RemoteException { registry.list(); }
Example 19
Source File: RmiRegistryFactoryBean.java From java-technology-stack with MIT License | 2 votes |
/** * Test the given RMI registry, calling some operation on it to * check whether it is still active. * <p>Default implementation calls {@code Registry.list()}. * @param registry the RMI registry to test * @throws RemoteException if thrown by registry methods * @see java.rmi.registry.Registry#list() */ protected void testRegistry(Registry registry) throws RemoteException { registry.list(); }
Example 20
Source File: RmiRegistryFactoryBean.java From spring-analysis-note with MIT License | 2 votes |
/** * Test the given RMI registry, calling some operation on it to * check whether it is still active. * <p>Default implementation calls {@code Registry.list()}. * @param registry the RMI registry to test * @throws RemoteException if thrown by registry methods * @see java.rmi.registry.Registry#list() */ protected void testRegistry(Registry registry) throws RemoteException { registry.list(); }