Spring configuration of local service
local.xml:
<bean id=“xxxService” class=“com.xxx.XxxServiceImpl” />
<bean id=“xxxAction” class=“com.xxx.XxxAction”>
<property name=“xxxService” ref=“xxxService” />
</bean>
Spring configuration of remote service
Spring远程服务配置
The remote configuration can be done by very little change based on the local configuration:
远程服务基于本地配置小小的改动就可以完成。
- split the
local.xml
into two part, put the service define part intoremote-privider.xml
(exists in the provider node), meanwhile the refrence part intoremote-consumer.xml
(exists in the consumer node). - 把local.xml切割成两部分,把定义服务的部分放在remote-provider.xml中(存在于提供端),与此同时引用部分放在remote-consumer.xml(存在于消费端节点)
- add
<dubbo:service>
to the provider's configuration, and<dubbo:reference>
to the consumer's configuration. - 添加<dubbo:service>到提供端配置,并且添加<dubbo:reference>到消费端配置。
remote-provider.xml:
远程提供者xml
<!-- define remote service bean the same way as local service bean -->
像本地服务bean一样定义远程服务bean
<bean id=“xxxService” class=“com.xxx.XxxServiceImpl” />
<!-- expose the remote service -->
暴露远程服务
<dubbo:service interface=“com.xxx.XxxService” ref=“xxxService” />
remote-consumer.xml:
远程消费端xml
<!-- reference the remote service -->
<dubbo:reference id=“xxxService” interface=“com.xxx.XxxService” />
<!-- use remote service the same say as local service -->
<bean id=“xxxAction” class=“com.xxx.XxxAction”>
<property name=“xxxService” ref=“xxxService” />
</bean>