<bean id="someService" class="com.filess.SomeServiceImpl"/>
<bean id="serviceExporter" class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="service">
<ref bean="someService"/>
</property>
<property name="serviceName">
<value>SomeService</value>
</property>
<property name="serviceInterface">
<value>com.filess.ISomeService</value>
</property>
<property name="registryPort">
<value>9000</value>
</property>
<property name="servicePort">
<value>9001</value>
</property>
</bean>
这个只有配置了一个接口,不会是把所有远程调用的类都放到这个接口吧,如果有许多接口应该怎么配置?
还有客户端得配置?
<bean id="serviceExporter" class="org.springframework.remoting.rmi.RmiServiceExporter">
<property name="service">
<ref bean="someService"/>
</property>
<property name="serviceName">
<value>SomeService</value>
</property>
<property name="serviceInterface">
<value>com.filess.ISomeService</value>
</property>
<property name="registryPort">
<value>9000</value>
</property>
<property name="servicePort">
<value>9001</value>
</property>
</bean>
这个只有配置了一个接口,不会是把所有远程调用的类都放到这个接口吧,如果有许多接口应该怎么配置?
还有客户端得配置?
--- 通常RMI不是每个service用一个接口,而是共享一个接口
service、serviceName和serviceInterface都不一样,端口可以相同。客户端的配置也很简单了: 1: <bean id="rmiClient_oper1" class="org.springframework.remoting.rmi.RmiProxyFactoryBean"> 2: <property name="serviceUrl"> 3: <value>rmi://192.168.0.***:9990/oper1</value> 4: </property> 5: <property name="serviceInterface"> 6: <value>***.IOper1</value> 7: </property> 8: </bean> 9: <bean id="rmiClient_oper2" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">10: <property name="serviceUrl">11: <value>rmi://192.168.0.***:9990/oper2</value>12: </property>13: <property name="serviceInterface">14: <value>***.IOper2</value>15: </property>16: </bean>
main里运行:1: public static void main(String[] args) {2: ApplicationContext ctx = new ClassPathXmlApplicationContext(3: "applicationContext-client.xml");4: IOper1 o1 = (IOper1) ctx.getBean("rmiClient_oper1");5: o1.exeuteFile();6: 7: IOper2 o2 = (IOper2) ctx.getBean("rmiClient_oper2");8: o2.printHelloWorld();9: }