Tôi đang cố gắng di chuyển Spring từ XmlApplicationContext
đến AnnotationConfigApplicationContext
(thông tin thêm: Java-based container configuration).Mùa xuân HttpRemoting khách hàng là một Bean Configuration Java
Mọi thứ hoạt động hoàn hảo nhưng tôi không biết cách tạo ứng dụng khách HttpInvoker. Cấu hình XML như sau:
<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>
Cấu hình Java nên trông như thế nào? Tôi vẫn cần Nhà máy Bean này? Tôi nghĩ rằng một trong những sẽ có thể nhanh chóng các khách hàng mà không có wrapper này với phương pháp cấu hình này.
này (bằng cách nào đó) cảm thấy xấu với tôi:
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();
}
đọc liên quan: http://blog.springsource.com/2011/08/10/beyond-the-factorybean –