在我的印象中,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