List of usage examples for org.springframework.remoting.httpinvoker HttpInvokerProxyFactoryBean setHttpInvokerRequestExecutor
public void setHttpInvokerRequestExecutor(HttpInvokerRequestExecutor httpInvokerRequestExecutor)
From source file:com.ish.client.ClientAppConfig.java
@Bean public HttpInvokerProxyFactoryBean httpInvokerProxy() throws Exception { HttpInvokerProxyFactoryBean proxyFactory = new HttpInvokerProxyFactoryBean(); proxyFactory.setServiceUrl("https://localhost:8443/rpc/account"); proxyFactory.setServiceInterface(AccountService.class); proxyFactory.setHttpInvokerRequestExecutor(http2InvokerRequestExecutor()); return proxyFactory; }
From source file:org.apache.servicemix.http.endpoints.SerializedMarshalerTest.java
public void testUsingSpringHttpRemoting() throws Exception { final Person person = new PersonImpl("Hunter", "Thompson", 67); // Create a consumer endpoint HttpConsumerEndpoint ep = new HttpConsumerEndpoint(); ep.setService(new QName("urn:HttpConsumer", "HttpConsumer")); ep.setEndpoint("HttpConsumer"); ep.setLocationURI("http://localhost:8192/service/"); ep.setTargetService(new QName("urn:HttpInvoker", "Endpoint")); // Configure the SerializedMarshaler and specifiy it on the endpoint SerializedMarshaler marshaler = new SerializedMarshaler(); marshaler.setDefaultMep(MessageExchangeSupport.IN_OUT); ep.setMarshaler(marshaler);//ww w. j av a 2s .c om // Add the endpoint to the component and activate it HttpComponent component = new HttpComponent(); component.setEndpoints(new HttpEndpointType[] { ep }); container.activateComponent(component, "HttpConsumer"); // Dummy up a component as a receiver and route it to urn:HttpInvoker/Endpoint TransformComponentSupport rmiComponent = new TransformComponentSupport() { protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws MessagingException { try { // Deserialize rmi invocation XStream xstream = new XStream(new DomDriver()); SourceTransformer st = new SourceTransformer(); Object rmi = xstream.fromXML(st.toString(in.getContent())); DefaultRemoteInvocationExecutor executor = new DefaultRemoteInvocationExecutor(); Object result = executor.invoke((RemoteInvocation) rmi, person); // Convert result to an rmi invocation RemoteInvocationResult rmiResult = new RemoteInvocationResult(result); out.setContent(new StringSource(xstream.toXML(rmiResult))); } catch (Exception e) { throw new MessagingException(e); } return true; } }; ActivationSpec asReceiver = new ActivationSpec("rmiComponent", rmiComponent); asReceiver.setService(new QName("urn:HttpInvoker", "Endpoint")); container.activateComponent(asReceiver); // Start the JBI container container.start(); // Set up the Spring bean to call into the URL specified for the consumer endpoint HttpInvokerProxyFactoryBean pfb = new HttpInvokerProxyFactoryBean(); pfb.setServiceInterface(Person.class); pfb.setServiceUrl("http://localhost:8192/service/"); pfb.setHttpInvokerRequestExecutor(new SimpleHttpInvokerRequestExecutor()); pfb.afterPropertiesSet(); // Grab the object via the proxy factory bean Person test = (Person) pfb.getObject(); // Test getters assertEquals("Hunter", test.getGivenName()); assertEquals("Thompson", test.getSurName()); assertEquals(67, test.getAge()); // Test setters test.setGivenName("John"); test.setSurName("Doe"); test.setAge(34); assertEquals(person.getGivenName(), "John"); assertEquals(person.getSurName(), "Doe"); assertEquals(person.getAge(), 34); }
From source file:de.scoopgmbh.copper.monitoring.client.context.ApplicationContext.java
protected void connect(final String serverAdressParam, final String user, final String password) { boolean secureConnect = StringUtils.hasText(user) && StringUtils.hasText(password); String serverAdress = serverAdressParam; if (!serverAdress.endsWith("/")) { serverAdress = serverAdress + "/"; }// w w w .j ava2 s. c o m final LoginService loginService; final CommonsHttpInvokerRequestExecutor httpInvokerRequestExecutor = new CommonsHttpInvokerRequestExecutor(); DefaultHttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(10, false); httpInvokerRequestExecutor.getHttpClient().getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler); httpInvokerRequestExecutor.getHttpClient().getParams().setSoTimeout(1000 * 60 * 5); { HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean(); httpInvokerProxyFactoryBean.setServiceUrl(serverAdress + "copperMonitoringService"); httpInvokerProxyFactoryBean.setServiceInterface(LoginService.class); httpInvokerProxyFactoryBean.setServiceUrl(serverAdress + "loginService"); httpInvokerProxyFactoryBean.afterPropertiesSet(); httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor); loginService = (LoginService) httpInvokerProxyFactoryBean.getObject(); } final String sessionId; if (secureConnect) { try { sessionId = loginService.doLogin(user, password); } catch (RemoteException e) { throw new RuntimeException(e); } } else { sessionId = ""; } if (sessionId == null) { getIssueReporterSingleton().reportWarning("Invalid user/password", null, new Runnable() { @Override public void run() { createLoginForm().show(); } }); } else { HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean(); httpInvokerProxyFactoryBean.setServiceUrl(serverAdress + "copperMonitoringService"); httpInvokerProxyFactoryBean.setServiceInterface(CopperMonitoringService.class); RemoteInvocationFactory remoteInvocationFactory = secureConnect ? new SecureRemoteInvocationFactory(sessionId) : new DefaultRemoteInvocationFactory(); httpInvokerProxyFactoryBean.setRemoteInvocationFactory(remoteInvocationFactory); httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor); httpInvokerProxyFactoryBean.afterPropertiesSet(); final CopperMonitoringService copperMonitoringService = (CopperMonitoringService) httpInvokerProxyFactoryBean .getObject(); final String serverAdressFinal = serverAdress; Platform.runLater(new Runnable() { @Override public void run() { setGuiCopperDataProvider(copperMonitoringService, serverAdressFinal, sessionId); } }); } }
From source file:org.copperengine.monitoring.client.context.ApplicationContext.java
protected void connect(final String serverAddressParam, final String user, final String password) { boolean secureConnect = StringUtils.hasText(user) && StringUtils.hasText(password); String serverAddress = serverAddressParam; if (!serverAddress.endsWith("/")) { serverAddress = serverAddress + "/"; }// w ww.j a va 2 s . c o m final LoginService loginService; final CommonsHttpInvokerRequestExecutor httpInvokerRequestExecutor = new CommonsHttpInvokerRequestExecutor(); DefaultHttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(10, false); httpInvokerRequestExecutor.getHttpClient().getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler); httpInvokerRequestExecutor.getHttpClient().getParams().setSoTimeout(1000 * 60 * 5); { HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean(); httpInvokerProxyFactoryBean.setServiceUrl(serverAddress + "copperMonitoringService"); httpInvokerProxyFactoryBean.setServiceInterface(LoginService.class); httpInvokerProxyFactoryBean.setServiceUrl(serverAddress + "loginService"); httpInvokerProxyFactoryBean.afterPropertiesSet(); httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor); loginService = (LoginService) httpInvokerProxyFactoryBean.getObject(); } final String sessionId; if (secureConnect) { try { sessionId = loginService.doLogin(user, password); } catch (RemoteException e) { throw new RuntimeException(e); } } else { sessionId = ""; } if (sessionId == null) { getIssueReporterSingleton().reportWarning("Invalid user/password", null, new Runnable() { @Override public void run() { createLoginForm().show(); } }); } else { HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean(); httpInvokerProxyFactoryBean.setServiceUrl(serverAddress + "copperMonitoringService"); httpInvokerProxyFactoryBean.setServiceInterface(CopperMonitoringService.class); RemoteInvocationFactory remoteInvocationFactory = secureConnect ? new SecureRemoteInvocationFactory(sessionId) : new DefaultRemoteInvocationFactory(); httpInvokerProxyFactoryBean.setRemoteInvocationFactory(remoteInvocationFactory); httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor); httpInvokerProxyFactoryBean.afterPropertiesSet(); final CopperMonitoringService copperMonitoringService = (CopperMonitoringService) httpInvokerProxyFactoryBean .getObject(); final String serverAddressFinal = serverAddress; Platform.runLater(new Runnable() { @Override public void run() { setGuiCopperDataProvider(copperMonitoringService, serverAddressFinal, sessionId); } }); } }
From source file:org.kuali.rice.kew.config.ThinClientResourceLoader.java
protected Object getServiceProxy(Class serviceInterface, String endpointParam, String secureEndpointParam) { HttpInvokerProxyFactoryBean proxyFactory = new HttpInvokerProxyFactoryBean(); String serviceUrl = ConfigContext.getCurrentContextConfig().getProperty(endpointParam); if (StringUtils.isEmpty(serviceUrl)) { throw new IllegalArgumentException( "The " + endpointParam + " configuration parameter was not defined but is required."); }/*from w w w .j av a 2 s .c om*/ proxyFactory.setServiceUrl(serviceUrl); proxyFactory.setServiceInterface(serviceInterface); String secureProp = ConfigContext.getCurrentContextConfig().getProperty(secureEndpointParam); Boolean secureIt = null; secureIt = secureProp == null || Boolean.valueOf(secureProp); KSBHttpInvokerRequestExecutor executor = new KSBHttpInvokerRequestExecutor(getHttpClient()); executor.setSecure(secureIt); proxyFactory.setHttpInvokerRequestExecutor(executor); proxyFactory.afterPropertiesSet(); return proxyFactory.getObject(); }
From source file:org.openflamingo.web.viz.VizController.java
/** * Remote File System Service .//from w w w . j a va 2 s . c om * * @return Remote Workflow Engine Service */ private FileSystemService getFileSystemService(String url) { HttpInvokerProxyFactoryBean factoryBean = new HttpInvokerProxyFactoryBean(); factoryBean.setServiceUrl(url); factoryBean.setServiceInterface(FileSystemService.class); HttpComponentsHttpInvokerRequestExecutor httpInvokerRequestExecutor = new HttpComponentsHttpInvokerRequestExecutor(); factoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor); factoryBean.afterPropertiesSet(); return (FileSystemService) factoryBean.getObject(); }