Java Code Examples for java.rmi.registry.Registry#lookup()
The following examples show how to use
java.rmi.registry.Registry#lookup() .
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: InheritedChannelNotServerSocket.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public synchronized Channel inheritedChannel() throws IOException { System.err.println("SP.inheritedChannel"); if (channel == null) { channel = SocketChannel.open(); Socket socket = channel.socket(); System.err.println("socket = " + socket); /* * Notify test that inherited channel was created. */ try { System.err.println("notify test..."); Registry registry = LocateRegistry.getRegistry(TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_REGISTRY_PORT); Callback obj = (Callback) registry.lookup("Callback"); obj.notifyTest(); } catch (NotBoundException nbe) { throw (IOException) new IOException("callback object not bound"). initCause(nbe); } } return channel; }
Example 2
Source File: JavaRMIIntegrationTest.java From tutorials with MIT License | 6 votes |
@Test public void whenClientSendsMessageToServer_thenServerSendsResponseMessage() { try { Registry registry = LocateRegistry.getRegistry(); MessengerService server = (MessengerService) registry.lookup("MessengerService"); String responseMessage = server.sendMessage("Client Message"); String expectedMessage = "Server Message"; assertEquals(responseMessage, expectedMessage); } catch (RemoteException e) { fail("Exception Occurred"); } catch (NotBoundException nb) { fail("Exception Occurred"); } }
Example 3
Source File: ShutdownImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) { try { int registryPort = Integer.parseInt(System.getProperty("rmi.registry.port")); Registry registry = LocateRegistry.getRegistry("", registryPort); ShutdownMonitor monitor = (ShutdownMonitor) registry.lookup(KeepAliveDuringCall.BINDING); System.err.println("(ShutdownImpl) retrieved shutdown monitor"); impl = new ShutdownImpl(monitor); Shutdown stub = (Shutdown) UnicastRemoteObject.exportObject(impl); System.err.println("(ShutdownImpl) exported shutdown object"); monitor.submitShutdown(stub); System.err.println("(ShutdownImpl) submitted shutdown object"); } catch (Exception e) { System.err.println("(ShutdownImpl) TEST SUBPROCESS FAILURE:"); e.printStackTrace(); } }
Example 4
Source File: RmidViaInheritedChannel.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public synchronized Channel inheritedChannel() throws IOException { System.err.println("RmidSelectorProvider.inheritedChannel"); if (channel == null) { /* * Create server socket channel and bind server socket. */ channel = ServerSocketChannel.open(); ServerSocket serverSocket = channel.socket(); serverSocket.bind( new InetSocketAddress(InetAddress.getLocalHost(), TestLibrary.RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT)); System.err.println("serverSocket = " + serverSocket); /* * Notify test that inherited channel was created. */ try { System.err.println("notify test..."); Registry registry = LocateRegistry.getRegistry(TestLibrary.RMIDVIAINHERITEDCHANNEL_REGISTRY_PORT); Callback obj = (Callback) registry.lookup("Callback"); obj.notifyTest(); } catch (NotBoundException nbe) { throw (IOException) new IOException("callback object not bound"). initCause(nbe); } } return channel; }
Example 5
Source File: SelfTerminator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { try { int registryPort = Integer.parseInt(System.getProperty("rmi.registry.port")); Registry registry = LocateRegistry.getRegistry("", registryPort); Remote stub = registry.lookup(LeaseCheckInterval.BINDING); Runtime.getRuntime().halt(0); } catch (Exception e) { e.printStackTrace(); } }
Example 6
Source File: RmidViaInheritedChannel.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public synchronized Channel inheritedChannel() throws IOException { System.err.println("RmidSelectorProvider.inheritedChannel"); if (channel == null) { /* * Create server socket channel and bind server socket. */ channel = ServerSocketChannel.open(); ServerSocket serverSocket = channel.socket(); serverSocket.bind( new InetSocketAddress(InetAddress.getLocalHost(), TestLibrary.RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT)); System.err.println("serverSocket = " + serverSocket); /* * Notify test that inherited channel was created. */ try { System.err.println("notify test..."); Registry registry = LocateRegistry.getRegistry(TestLibrary.RMIDVIAINHERITEDCHANNEL_REGISTRY_PORT); Callback obj = (Callback) registry.lookup("Callback"); obj.notifyTest(); } catch (NotBoundException nbe) { throw (IOException) new IOException("callback object not bound"). initCause(nbe); } } return channel; }
Example 7
Source File: DUnitLauncher.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void init(Registry registry) throws AccessException, RemoteException, NotBoundException { for(int i = 0; i < numVms; i++) { RemoteTestModuleIF remote = (RemoteTestModuleIF) registry.lookup("vm" + i); addVM(i, "vm" + i, remote); } //for ease of debugging, add another VM that is the local host. addVM(numVms, "vm" + numVms, new FakeRemoteTestModule(Log.getLogWriter())); addLocator(numVms+1, "vm" + numVms + 1, (RemoteTestModuleIF) registry.lookup("vm" + NUM_VMS)); addHost(this); }
Example 8
Source File: SelfTerminator.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { try { int registryPort = Integer.parseInt(System.getProperty("rmi.registry.port")); Registry registry = LocateRegistry.getRegistry("", registryPort); Remote stub = registry.lookup(LeaseCheckInterval.BINDING); Runtime.getRuntime().halt(0); } catch (Exception e) { e.printStackTrace(); } }
Example 9
Source File: Client.java From odo with Apache License 2.0 | 5 votes |
/** * Returns whether or not the host editor service is available * * @return * @throws Exception */ public static boolean isAvailable() throws Exception { try { Registry myRegistry = LocateRegistry.getRegistry("127.0.0.1", port); com.groupon.odo.proxylib.hostsedit.rmi.Message impl = (com.groupon.odo.proxylib.hostsedit.rmi.Message) myRegistry.lookup(SERVICE_NAME); return true; } catch (Exception e) { return false; } }
Example 10
Source File: RMICommChannelFactory.java From jolie with GNU Lesser General Public License v2.1 | 5 votes |
public CommChannel createChannel( URI location, OutputPort port ) throws IOException { try { Registry registry = LocateRegistry.getRegistry( location.getHost(), location.getPort() ); JolieRemote remote = (JolieRemote) registry.lookup( location.getPath() ); return new RMICommChannel( remote.createRemoteBasicChannel() ); } catch( NotBoundException e ) { throw new IOException( e ); } }
Example 11
Source File: DUnitLauncher.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public void init(Registry registry) throws AccessException, RemoteException, NotBoundException { for(int i = 0; i < numVms; i++) { RemoteTestModuleIF remote = (RemoteTestModuleIF) registry.lookup("vm" + i); addVM(i, "vm" + i, remote); } //for ease of debugging, add another VM that is the local host. addVM(numVms, "vm" + numVms, new FakeRemoteTestModule(Log.getLogWriter())); addLocator(numVms+1, "vm" + numVms + 1, (RemoteTestModuleIF) registry.lookup("vm" + NUM_VMS)); addHost(this); }
Example 12
Source File: RmidViaInheritedChannel.java From hottub with GNU General Public License v2.0 | 5 votes |
public synchronized Channel inheritedChannel() throws IOException { System.err.println("RmidSelectorProvider.inheritedChannel"); if (channel == null) { /* * Create server socket channel and bind server socket. */ channel = ServerSocketChannel.open(); ServerSocket serverSocket = channel.socket(); serverSocket.bind( new InetSocketAddress(InetAddress.getLocalHost(), TestLibrary.RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT)); System.err.println("serverSocket = " + serverSocket); /* * Notify test that inherited channel was created. */ try { System.err.println("notify test..."); Registry registry = LocateRegistry.getRegistry(TestLibrary.RMIDVIAINHERITEDCHANNEL_REGISTRY_PORT); Callback obj = (Callback) registry.lookup("Callback"); obj.notifyTest(); } catch (NotBoundException nbe) { throw (IOException) new IOException("callback object not bound"). initCause(nbe); } } return channel; }
Example 13
Source File: ServerTestUtil.java From ghidra with Apache License 2.0 | 5 votes |
private static boolean isServerRegistered(int port) throws IOException { Registry reg = LocateRegistry.getRegistry(LOCALHOST, port, new SslRMIClientSocketFactory()); try { reg.lookup(GhidraServerHandle.BIND_NAME); return true; } catch (Exception ce) { return false; } }
Example 14
Source File: SelfTerminator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { try { int registryPort = Integer.parseInt(System.getProperty("rmi.registry.port")); Registry registry = LocateRegistry.getRegistry("", registryPort); Remote stub = registry.lookup(LeaseCheckInterval.BINDING); Runtime.getRuntime().halt(0); } catch (Exception e) { e.printStackTrace(); } }
Example 15
Source File: RmidViaInheritedChannel.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public synchronized Channel inheritedChannel() throws IOException { System.err.println("RmidSelectorProvider.inheritedChannel"); if (channel == null) { /* * Create server socket channel and bind server socket. */ channel = ServerSocketChannel.open(); ServerSocket serverSocket = channel.socket(); serverSocket.bind( new InetSocketAddress(InetAddress.getLocalHost(), TestLibrary.RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT)); System.err.println("serverSocket = " + serverSocket); /* * Notify test that inherited channel was created. */ try { System.err.println("notify test..."); Registry registry = LocateRegistry.getRegistry(TestLibrary.RMIDVIAINHERITEDCHANNEL_REGISTRY_PORT); Callback obj = (Callback) registry.lookup("Callback"); obj.notifyTest(); } catch (NotBoundException nbe) { throw (IOException) new IOException("callback object not bound"). initCause(nbe); } } return channel; }
Example 16
Source File: MultipleRegistries.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { RemoteInterface server = null; RemoteInterface proxy = null; try { System.err.println("export object"); server = new MultipleRegistries(); proxy = (RemoteInterface) UnicastRemoteObject.exportObject(server, 0); System.err.println("proxy = " + proxy); System.err.println("export registries"); Registry registryImpl1 = TestLibrary.createRegistryOnUnusedPort(); int port1 = TestLibrary.getRegistryPort(registryImpl1); Registry registryImpl2 = TestLibrary.createRegistryOnUnusedPort(); int port2 = TestLibrary.getRegistryPort(registryImpl2); System.err.println("bind remote object in registries"); Registry registry1 = LocateRegistry.getRegistry(port1); Registry registry2 = LocateRegistry.getRegistry(port2); registry1.bind(NAME, proxy); registry2.bind(NAME, proxy); System.err.println("lookup remote object in registries"); RemoteInterface remote1 = (RemoteInterface) registry1.lookup(NAME); RemoteInterface remote2 = (RemoteInterface) registry2.lookup(NAME); System.err.println("invoke methods on remote objects"); remote1.passObject(remote1); remote2.passObject(remote2); System.err.println("TEST PASSED"); } finally { if (proxy != null) { UnicastRemoteObject.unexportObject(server, true); } } }
Example 17
Source File: MultipleRegistries.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { RemoteInterface server = null; RemoteInterface proxy = null; try { System.err.println("export object"); server = new MultipleRegistries(); proxy = (RemoteInterface) UnicastRemoteObject.exportObject(server, 0); System.err.println("proxy = " + proxy); System.err.println("export registries"); Registry registryImpl1 = TestLibrary.createRegistryOnUnusedPort(); int port1 = TestLibrary.getRegistryPort(registryImpl1); Registry registryImpl2 = TestLibrary.createRegistryOnUnusedPort(); int port2 = TestLibrary.getRegistryPort(registryImpl2); System.err.println("bind remote object in registries"); Registry registry1 = LocateRegistry.getRegistry(port1); Registry registry2 = LocateRegistry.getRegistry(port2); registry1.bind(NAME, proxy); registry2.bind(NAME, proxy); System.err.println("lookup remote object in registries"); RemoteInterface remote1 = (RemoteInterface) registry1.lookup(NAME); RemoteInterface remote2 = (RemoteInterface) registry2.lookup(NAME); System.err.println("invoke methods on remote objects"); remote1.passObject(remote1); remote2.passObject(remote2); System.err.println("TEST PASSED"); } finally { if (proxy != null) { UnicastRemoteObject.unexportObject(server, true); } } }
Example 18
Source File: MultipleRegistries.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { RemoteInterface server = null; RemoteInterface proxy = null; try { System.err.println("export object"); server = new MultipleRegistries(); proxy = (RemoteInterface) UnicastRemoteObject.exportObject(server, 0); System.err.println("proxy = " + proxy); System.err.println("export registries"); Registry registryImpl1 = TestLibrary.createRegistryOnUnusedPort(); int port1 = TestLibrary.getRegistryPort(registryImpl1); Registry registryImpl2 = TestLibrary.createRegistryOnUnusedPort(); int port2 = TestLibrary.getRegistryPort(registryImpl2); System.err.println("bind remote object in registries"); Registry registry1 = LocateRegistry.getRegistry(port1); Registry registry2 = LocateRegistry.getRegistry(port2); registry1.bind(NAME, proxy); registry2.bind(NAME, proxy); System.err.println("lookup remote object in registries"); RemoteInterface remote1 = (RemoteInterface) registry1.lookup(NAME); RemoteInterface remote2 = (RemoteInterface) registry2.lookup(NAME); System.err.println("invoke methods on remote objects"); remote1.passObject(remote1); remote2.passObject(remote2); System.err.println("TEST PASSED"); } finally { if (proxy != null) { UnicastRemoteObject.unexportObject(server, true); } } }
Example 19
Source File: Client.java From odo with Apache License 2.0 | 3 votes |
/** * Returns whether a host exists * * @param hostName * @return * @throws Exception */ public static boolean exists(String hostName) throws Exception { Registry myRegistry = LocateRegistry.getRegistry("127.0.0.1", port); com.groupon.odo.proxylib.hostsedit.rmi.Message impl = (com.groupon.odo.proxylib.hostsedit.rmi.Message) myRegistry.lookup(SERVICE_NAME); return impl.exists(hostName); }
Example 20
Source File: Client.java From odo with Apache License 2.0 | 3 votes |
/** * Returns whether a host is enabled * * @param hostName * @return * @throws Exception */ public static boolean isEnabled(String hostName) throws Exception { Registry myRegistry = LocateRegistry.getRegistry("127.0.0.1", port); com.groupon.odo.proxylib.hostsedit.rmi.Message impl = (com.groupon.odo.proxylib.hostsedit.rmi.Message) myRegistry.lookup(SERVICE_NAME); return impl.isEnabled(hostName); }