Spring目前提供了对HttpInvoker、Hessian、Burlap等Remoting技术的集成。
Spring屏蔽了这些实现技术的差异,用户只需开发简单的Java对象(Plain Old Java Objects,POJO)然后按照Spring规定的格式进行配置文件的编写即可,提高效率,而且几种调用方式之间可以平滑切换,只需要更改配置文件,不需要更改具体的代码。
名称 | 技术 | 语言 |
---|---|---|
http invoker | 基于java序列化传输数据 | 仅支持java |
hessian | 基于二进制流传输数据 | 跨语言,字节数少,性能较优 |
burlap | 基于xml传输数据 | 跨语言,数据冗余,xml格式描述性好 |
<bean id="productServiceHessian" class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
<property name="serviceUrl" value="http://127.0.0.1:8300/productService.servicehessian"/>
<property name="serviceInterface" value="com.xxxxx.biz.service.ProductService"/>
</bean>
<bean id="productServiceBurlap" class="org.springframework.remoting.caucho.BurlapProxyFactoryBean">
<property name="serviceUrl" value="http://127.0.0.1:8300/productService.serviceburlap"/>
<property name="serviceInterface" value="com.xxxxx.service.ProductService"/>
</bean>
<bean id="productService" class="com.xxxxx.service.impl.ProductServiceImpl"></bean>
<bean name="/productService.servicehessian" class="org.springframework.remoting.caucho.HessianServiceExporter">
<property name="service" ref="productService" />
<property name="serviceInterface" value="com.xxxxx.service.ProductService" />
</bean>
<bean name="/productService.serviceburlap" class="org.springframework.remoting.caucho.BurlapServiceExporter">
<property name="service" ref="productService" />
<property name="serviceInterface" value="com.xxxxx.service.ProductService" />
</bean>
详细介绍见:http://blog.csdn.net/lsblsb/article/details/39930503
过程中遇到的小问题:
解决HessianProtocolException: expected string at 0x6d : http://blog.csdn.net/lsblsb/article/details/39994461
关于spring的httpinvoker调用详细介绍见:http://blog.csdn.net/lsblsb/article/details/39930503
参考:http://www.iteye.com/topic/417767
java 几种远程服务调用协议的比较:http://www.360doc.com/content/12/0220/13/2795334_188038946.shtml