/** {@inheritDoc} */ public LocalSave createProxy(String user) { RmiProxyFactoryBean proxyFactory = new RmiProxyFactoryBean(); proxyFactory.setServiceUrl("rmi://" + user + ":8989/LocalSave"); proxyFactory.setServiceInterface(LocalSave.class); proxyFactory.afterPropertiesSet(); return (LocalSave) proxyFactory.getObject(); }
@Bean public QuoteService quoteServiceBean() { RmiProxyFactoryBean factory = new RmiProxyFactoryBean(); factory.setServiceUrl("rmi://localhost:1099/QuoteService"); factory.setServiceInterface(QuoteService.class); factory.afterPropertiesSet(); return (QuoteService) factory.getObject(); }
/** @return */ private Object buildStub() { RmiProxyFactoryBean remoteStub = new RmiProxyFactoryBean(); remoteStub.setLookupStubOnStartup(true); remoteStub.setRefreshStubOnConnectFailure(true); remoteStub.setCacheStub(true); remoteStub.setServiceUrl(serviceUrl); remoteStub.setServiceInterface(serviceInterface); remoteStub.afterPropertiesSet(); return remoteStub.getObject(); }
public RemoteNodeRegistration startProxy() { RmiProxyFactoryBean proxyFactory = new RmiProxyFactoryBean(); proxyFactory.setServiceUrl( "rmi://" + props.getProperty("server.ip") + ":8989/RemoteNodeRegistration"); proxyFactory.setServiceInterface(RemoteNodeRegistration.class); proxyFactory.afterPropertiesSet(); return (RemoteNodeRegistration) proxyFactory.getObject(); }
/** Connect to the remote servers. */ private static List<LoaderServerProxy> connect( Set<String> rmiUrls, String username, String password) throws Exception { List<LoaderServerProxy> remoteServers = new ArrayList<LoaderServerProxy>(rmiUrls.size()); for (String rmiUrl : rmiUrls) { try { // Ensure the RMI URL is consistent if (!rmiUrl.endsWith("/")) { rmiUrl += "/"; } // Get the FileFolderServiceTransport FileFolderRemoteClient fileFolderRemote = new FileFolderRemoteClient(rmiUrl); // Get the LoaderServiceTransport RmiProxyFactoryBean loaderFactory = new RmiProxyFactoryBean(); loaderFactory.setRefreshStubOnConnectFailure(true); loaderFactory.setServiceInterface(LoaderRemote.class); loaderFactory.setServiceUrl(rmiUrl + LoaderRemote.SERVICE_NAME); loaderFactory.afterPropertiesSet(); LoaderRemote loaderRemote = (LoaderRemote) loaderFactory.getObject(); // Authenticate String ticket = loaderRemote.authenticate(username, password); // Store the service references LoaderServerProxy remoteServer = new LoaderServerProxy(rmiUrl, ticket, fileFolderRemote, loaderRemote); remoteServers.add(remoteServer); } catch (Throwable e) { // Failed to connect. System.err.println( "\n" + "ERROR: Failed to establish connection to server: \n" + " Server: " + rmiUrl + "\n" + " Error: " + e.getMessage()); e.printStackTrace(); } } // Check that there is at least one server if (remoteServers.size() == 0) { throw new LoaderClientException("No remote servers are available"); } return remoteServers; }