在我的印象中,RmiProxyFactoryBean
应该产生一个类型为AccountService
的代理对象实例,它将在SimpleObject
实例的accountService
属性中注入以下代码。Spring如何知道代理对象需要注入哪里?
我不明白为什么XML文件似乎指示Spring将RmiProxyFactoryBean
类型的对象注入accountService
SimpleObject
对象实例的属性?我在等,告诉Spring是如何从RmiProxyFactoryBean
实例得到AccountService
实例,而不是注入RmiProxyFactoryBean
实例的XML文件的明确指令。我觉得这很混乱。
public class SimpleObject {
private AccountService accountService;
public void setAccountService(AccountService accountService) {
this.accountService = accountService;
}
}
<bean class="example.SimpleObject">
<property name="accountService" ref="accountService"/>
</bean>
<bean id="accountService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
<property name="serviceUrl" value="rmi://HOST:1199/AccountService"/>
<property name="serviceInterface" value="example.AccountService"/>
</bean>
来源: http://static.springsource.org/spring/docs/2.5.x/reference/remoting.html (见17.2.2。)
由于
看起来很完美,谢谢彼得 – supertonsky