Spring HttpRemoting Client as a Java Bean Configuration

I am trying to migrate Spring from XmlApplicationContext to AnnotationConfigApplicationContext (more: Java container configuration ).

Everything works fine, but I donโ€™t know how to create an HttpInvoker client. The XML configuration is as follows:

 <bean id="httpInvokerProxy" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean"> <property name="serviceUrl" value="http://remotehost:8080/remoting/AccountService"/> <property name="serviceInterface" value="example.AccountService"/> </bean> 

What should the Java configuration look like? Do I still need this Factory Bean? I think you need to create a client instance without this shell using this configuration method.

This (somehow) is bad for me:

 public @Bean AccountService httpInvokerProxy() { HttpInvokerProxyFactoryBean proxy = new HttpInvokerProxyFactoryBean(); proxy.setServiceInterface(AccountService.class); proxy.setServiceUrl("http://remotehost:8080/remoting/AccountService"); proxy.afterPropertiesSet(); return (AccountService) proxy.getObject(); } 
+8
java spring spring-remoting
source share
1 answer

Actually, the correct (and equivalent) version will be even more inconvenient:

 public @Bean HttpInvokerProxyFactoryBean httpInvokerProxy() { HttpInvokerProxyFactoryBean proxy = new HttpInvokerProxyFactoryBean(); proxy.setServiceInterface(AccountService.class); proxy.setServiceUrl("http://remotehost:8080/remoting/AccountService"); return proxy; } 

(In the end, you usually want FactoryBean to be managed using Spring, not Bean.)

See this article for reference:

What is FactoryBean?

+8
source

All Articles