I'm trying to migrate Spring from XmlApplicationContext
to AnnotationConfigApplicationContext
(more info: Java-based container configuration).
Everything works perfectly but I don't know how to create a 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>
How should the Java Configuration look? Do I still need this Factory Bean? I think one should be able to instantiate the client without this wrapper with this configuration method.
This (somehow) feels bad to 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();
}