List of usage examples for java.rmi.registry LocateRegistry getRegistry
public static Registry getRegistry(String host, int port, RMIClientSocketFactory csf) throws RemoteException
Registry
on the specified host
and port
. From source file:com.machinepublishers.jbrowserdriver.JBrowserDriver.java
/** * Use {@link Settings#builder()} ...build() to create settings to pass to this constructor. * /*from w w w .j ava 2s . c o m*/ * @param settings */ public JBrowserDriver(final Settings settings) { synchronized (locks) { locks.add(lock); } File tmpDir = null; try { tmpDir = Files.createTempDirectory("jbd_tmp_").toFile(); } catch (Throwable t) { Util.handleException(t); } this.tmpDir = tmpDir; this.shutdownHook = new FileRemover(tmpDir); Runtime.getRuntime().addShutdownHook(shutdownHook); final Job job = new Job(settings, configuredPortGroup); synchronized (waiting) { waiting.add(job); waiting.notifyAll(); } synchronized (job) { while (configuredPortGroup.get() == null) { try { job.wait(); } catch (InterruptedException e) { } } } SessionId sessionIdTmp = null; if (!settings.customClasspath()) { synchronized (firstLaunch) { if (firstLaunch.compareAndSet(true, false)) { initClasspath(); classpathArgs.set(classpathUnpackedArgs); sessionIdTmp = new SessionId(launchProcess(settings, configuredPortGroup.get())); if (actualPortGroup.get() == null) { classpathArgs.set(classpathSimpleArgs); } } } } if (actualPortGroup.get() == null) { sessionIdTmp = new SessionId(launchProcess(settings, configuredPortGroup.get())); } sessionId = sessionIdTmp; if (actualPortGroup.get() == null) { endProcess(); Util.handleException(new IllegalStateException("Could not launch browser.")); } JBrowserDriverRemote instanceTmp = null; try { synchronized (lock.validated()) { instanceTmp = (JBrowserDriverRemote) LocateRegistry .getRegistry(settings.host(), (int) actualPortGroup.get().child, new SocketFactory(settings.host(), actualPortGroup.get(), locks)) .lookup("JBrowserDriverRemote"); instanceTmp.setUp(settings); } } catch (Throwable t) { Util.handleException(t); } remote = instanceTmp; LogsRemote logsRemote = null; try { synchronized (lock.validated()) { logsRemote = remote.logs(); } } catch (Throwable t) { Util.handleException(t); } logs = new Logs(logsRemote, lock); }
From source file:org.jgentleframework.integration.remoting.rmi.support.RmiExecutor.java
/** * Gets the registry./*from ww w.j a v a 2 s . co m*/ * * @param registryPort * the registry port * @param clientSocketFactory * the client socket factory * @param serverSocketFactory * the server socket factory * @param autoCreateRegistry * the auto create registry * @return {@link Registry} * @throws RemoteException * the remote exception */ public static Registry getRegistry(boolean autoCreateRegistry, int registryPort, RMIClientSocketFactory clientSocketFactory, RMIServerSocketFactory serverSocketFactory) throws RemoteException { if (clientSocketFactory != null) { if (autoCreateRegistry) { return LocateRegistry.createRegistry(registryPort, clientSocketFactory, serverSocketFactory); } try { Registry reg = LocateRegistry.getRegistry(null, registryPort, clientSocketFactory); testRegistry(reg); return reg; } catch (RemoteException ex) { return LocateRegistry.createRegistry(registryPort, clientSocketFactory, serverSocketFactory); } } else { return getRegistry(autoCreateRegistry, registryPort); } }
From source file:org.jgentleframework.integration.remoting.rmi.support.RmiExecutor.java
/** * Gets the registry.//from w w w .ja va 2s . c om * * @param registryHost * the registry host * @param registryPort * the registry port * @param clientSocketFactory * the client socket factory * @param serverSocketFactory * the server socket factory * @param autoCreateRegistry * the auto create registry * @return {@link Registry} * @throws RemoteException * the remote exception */ protected static Registry getRegistry(boolean autoCreateRegistry, String registryHost, int registryPort, RMIClientSocketFactory clientSocketFactory, RMIServerSocketFactory serverSocketFactory) throws RemoteException { if (registryHost != null && !registryHost.isEmpty()) { if (log.isInfoEnabled()) { log.info("Looking for RMI registry at port '" + registryPort + "' of host [" + registryHost + "]"); } Registry reg = LocateRegistry.getRegistry(registryHost, registryPort, clientSocketFactory); // Kim tra registry. testRegistry(reg); return reg; } else { return getRegistry(autoCreateRegistry, registryPort, clientSocketFactory, serverSocketFactory); } }
From source file:org.springframework.remoting.rmi.RmiRegistryFactoryBean.java
/** * Locate or create the RMI registry.//from w w w .j a va2 s.c o m * @param registryHost the registry host to use (if this is specified, * no implicit creation of a RMI registry will happen) * @param registryPort the registry port to use * @param clientSocketFactory the RMI client socket factory for the registry (if any) * @param serverSocketFactory the RMI server socket factory for the registry (if any) * @return the RMI registry * @throws java.rmi.RemoteException if the registry couldn't be located or created */ protected Registry getRegistry(String registryHost, int registryPort, @Nullable RMIClientSocketFactory clientSocketFactory, @Nullable RMIServerSocketFactory serverSocketFactory) throws RemoteException { if (registryHost != null) { // Host explicitly specified: only lookup possible. if (logger.isInfoEnabled()) { logger.info( "Looking for RMI registry at port '" + registryPort + "' of host [" + registryHost + "]"); } Registry reg = LocateRegistry.getRegistry(registryHost, registryPort, clientSocketFactory); testRegistry(reg); return reg; } else { return getRegistry(registryPort, clientSocketFactory, serverSocketFactory); } }
From source file:org.springframework.remoting.rmi.RmiRegistryFactoryBean.java
/** * Locate or create the RMI registry./* w w w. ja v a 2 s.com*/ * @param registryPort the registry port to use * @param clientSocketFactory the RMI client socket factory for the registry (if any) * @param serverSocketFactory the RMI server socket factory for the registry (if any) * @return the RMI registry * @throws RemoteException if the registry couldn't be located or created */ protected Registry getRegistry(int registryPort, @Nullable RMIClientSocketFactory clientSocketFactory, @Nullable RMIServerSocketFactory serverSocketFactory) throws RemoteException { if (clientSocketFactory != null) { if (this.alwaysCreate) { logger.info("Creating new RMI registry"); this.created = true; return LocateRegistry.createRegistry(registryPort, clientSocketFactory, serverSocketFactory); } if (logger.isInfoEnabled()) { logger.info("Looking for RMI registry at port '" + registryPort + "', using custom socket factory"); } synchronized (LocateRegistry.class) { try { // Retrieve existing registry. Registry reg = LocateRegistry.getRegistry(null, registryPort, clientSocketFactory); testRegistry(reg); return reg; } catch (RemoteException ex) { logger.debug("RMI registry access threw exception", ex); logger.info("Could not detect RMI registry - creating new one"); // Assume no registry found -> create new one. this.created = true; return LocateRegistry.createRegistry(registryPort, clientSocketFactory, serverSocketFactory); } } } else { return getRegistry(registryPort); } }
From source file:org.ut.biolab.medsavant.MedSavantClient.java
public static void initializeRegistry(String serverAddress, String serverPort) throws RemoteException, NotBoundException, NoRouteToHostException, ConnectIOException { if (initialized) { return;/* w w w.java 2s . com*/ } int port = (new Integer(serverPort)).intValue(); Registry registry; LOG.debug("Connecting to MedSavantServerEngine @ " + serverAddress + ":" + serverPort + "..."); try { registry = LocateRegistry.getRegistry(serverAddress, port, new SslRMIClientSocketFactory()); LOG.debug("Retrieving adapters..."); setAdaptersFromRegistry(registry); LOG.info("Connected with SSL/TLS Encryption"); } catch (ConnectIOException ex) { if (ex.getCause() instanceof SSLHandshakeException) { registry = LocateRegistry.getRegistry(serverAddress, port); LOG.debug("Retrieving adapters..."); setAdaptersFromRegistry(registry); LOG.info("Connected without SSL/TLS encryption"); } } LOG.debug("Done"); }
From source file:org.ut.biolab.medsavant.MedSavantServlet.java
public void initializeRegistry(String serverAddress, String serverPort) throws RemoteException, NotBoundException, NoRouteToHostException, ConnectIOException { if (initialized) { return;// w w w .ja va 2 s .c o m } int port = (new Integer(serverPort)).intValue(); Registry registry; LOG.info("Connecting to MedSavantServerEngine @ " + serverAddress + ":" + serverPort + "..."); try { registry = LocateRegistry.getRegistry(serverAddress, port, new SslRMIClientSocketFactory()); LOG.debug("Retrieving adapters..."); setAdaptersFromRegistry(registry); setLocalAdapters(); LOG.info("Connected with SSL/TLS Encryption"); initialized = true; } catch (ConnectIOException ex) { if (ex.getCause() instanceof SSLHandshakeException) { registry = LocateRegistry.getRegistry(serverAddress, port); LOG.info("Retrieving adapters..."); setAdaptersFromRegistry(registry); LOG.info("Connected without SSL/TLS encryption"); } } LOG.info("Done"); }