List of usage examples for org.springframework.remoting.rmi RmiProxyFactoryBean afterPropertiesSet
@Override public void afterPropertiesSet()
From source file:com.rk.grid.cluster.slave.NodeMain.java
@SuppressWarnings("unchecked") public static void main(String[] args) throws IOException { String host = "localhost"; String port = null;//from w w w . j a v a 2s . c o m int indx = 0; String serviceName = null; System.out.println("Node bootstrap params: " + Arrays.asList(args)); while (indx < args.length && args[indx].startsWith("-")) { if (args[indx].equalsIgnoreCase("-p")) { port = args[++indx]; log("Port=" + port); } else if (args[indx].equalsIgnoreCase("-h")) { host = args[++indx]; log("Host=" + host); } else if (args[indx].equalsIgnoreCase("-b")) { serviceName = args[++indx]; log("Broker ServiceName=" + serviceName); } indx++; } if (port == null) { throw new RuntimeException("Port not set"); } if (serviceName == null) { throw new RuntimeException("Broker Service Name not set"); } RmiProxyFactoryBean s = new RmiProxyFactoryBean(); s.setServiceUrl("rmi://" + host + ":" + port + "/" + serviceName); s.setServiceInterface(IBroker.class); s.afterPropertiesSet(); IBroker<Object> broker = (IBroker<Object>) s.getObject(); RemoteExecutorNode<Object> remoteExecutor = new RemoteExecutorNode<Object>(broker); GridConfig gridConfig = broker.getBrokerInfo().getConfig(); if (gridConfig.libraryPathDefined()) { String libraryPath = gridConfig.getLibraryPath(); ClassLoader loader = getClassLoader(libraryPath); Thread.currentThread().setContextClassLoader(loader); } InjectionInterceptor interceptor = new InjectionInterceptor(); if (gridConfig.injectionContextDefined()) { String injectionContext = gridConfig.getInjectionContext(); ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(injectionContext); interceptor.setContext(ctx); } interceptor.addBean("monitor", broker.getProgressMonitor()); remoteExecutor.add(interceptor); remoteExecutor.start(); }
From source file:com.rk.grid.federation.FederatedCluster.java
@SuppressWarnings("unchecked") private static IBroker<Object> getConnection(String serviceName, int port, String host) { RmiProxyFactoryBean s = new RmiProxyFactoryBean(); s.setServiceUrl("rmi://" + host + ":" + port + "/" + serviceName); s.setServiceInterface(IBroker.class); s.afterPropertiesSet(); IBroker<Object> broker = (IBroker<Object>) s.getObject(); return broker; }
From source file:com.mysoft.b2b.event.scheduler.protocol.rmi.RMIClientHelper.java
public static ProtocolService getRMIProtocolService(String protocolUrl) { String serviceUrl = ""; if (protocolUrl != null && protocolUrl.endsWith("/")) { serviceUrl = protocolUrl;/* w w w .j av a2s.c om*/ } else { serviceUrl = protocolUrl + "/"; } serviceUrl = serviceUrl + ProtocolService.class.getSimpleName(); RmiProxyFactoryBean rpfb = new RmiProxyFactoryBean(); rpfb.setServiceUrl(serviceUrl); rpfb.setServiceInterface(ProtocolService.class); try { rpfb.setLookupStubOnStartup(false); rpfb.setRefreshStubOnConnectFailure(true); rpfb.afterPropertiesSet(); } catch (Exception e) { logger.info("Can't get the remote RMI server: " + serviceUrl + ", because " + e.getMessage()); return null; } logger.info("Success to init RMI local proxy service for " + serviceUrl); return (ProtocolService) rpfb.getObject(); }
From source file:au.com.jwatmuff.genericp2p.rmi.RMIPeerManager.java
@SuppressWarnings("unchecked") private static <T> T getService(InetSocketAddress address, String serviceName, Class<T> serviceClass) throws NoSuchServiceException { String url = "rmi://" + address.getHostName() + ":" + address.getPort() + "/" + serviceName; try {//from w w w . j a v a2s.c om /* maybe should use address.getAddress().getHostAddress() */ RmiProxyFactoryBean factory = new RmiProxyFactoryBean(); factory.setServiceInterface(serviceClass); factory.setServiceUrl(url); factory.afterPropertiesSet(); return (T) factory.getObject(); } catch (RemoteLookupFailureException rlfe) { throw new NoSuchServiceException("Unable to resolve service " + serviceName + " at url: " + url); } catch (Exception e) { throw new RuntimeException("getService failed", e); } }
From source file:com.apress.prospringintegration.springenterprise.stocks.client.RMIClientConfig.java
@Bean public QuoteService quoteServiceBean() { RmiProxyFactoryBean factory = new RmiProxyFactoryBean(); factory.setServiceUrl("rmi://localhost:1099/QuoteService"); factory.setServiceInterface(QuoteService.class); factory.afterPropertiesSet(); return (QuoteService) factory.getObject(); }
From source file:net.dfs.remote.main.ClientServicesStarter.java
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(); }