spring-remoting调用的介绍

来源:互联网 发布:linux下安装chrome 编辑:程序博客网 时间:2024/06/05 07:42


1. 总体介绍

Spring目前提供了对HttpInvoker、Hessian、Burlap等Remoting技术的集成。
Spring屏蔽了这些实现技术的差异,用户只需开发简单的Java对象(Plain Old Java Objects,POJO)然后按照Spring规定的格式进行配置文件的编写即可,提高效率,而且几种调用方式之间可以平滑切换,只需要更改配置文件,不需要更改具体的代码。


对比介绍名称技术语言http invoker基于java序列化传输数据仅支持javahessian基于二进制流传输数据跨语言,字节数少,性能较优burlap基于xml传输数据跨语言,数据冗余,xml格式描述性好


2.客户端配置

<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>


3. 服务端配置

<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>


4. 单元测试

详细介绍见:http://blog.csdn.net/lsblsb/article/details/39930503

5. 其他

过程中遇到的小问题:

解决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

0 0