批改phprpc源码以支持集合类的string类型的转换

WBOY
Release: 2016-06-13 10:39:47
Original
747 people have browsed it

修改phprpc源码以支持集合类的string类型的转换
就remoting协议而言,用得比较多的是hessian与phprpc,但phprpc的转化效率比hessian高很多。以下链接是牛人对此两者的序列化/反序列化效率作出的比较:
http://www.iteye.com/topic/333720
我因为开发的需要,对两者能支持的数据类型也进行了一些测试和比较,总结如下:

hessian
1.不支持集合内含有char数组;
2.除1外,完美支持各种集合、元素类型的解析转换;

phprpc
1.不支持集合内value为string类型的值,需由客户自己转换,代码如:new String((byte[])test.getMap().get("1"),"utf-8")
2.集合内除byte[]外,不支持其它数组,如int[]、float[]、char[]等

乍一看觉得用hessian就够了,虽然hessian对集合内的char数组不支持转换,但是由于在实际运用中使用机率较低。但是眼看着效率高hessian N倍的phprpc不用怪蛋痛,于是着手研究代码,企图从源码解决这个不支持集合内value为string类型值的问题。
其实问题原因在于PHPRPC在反序列化(unserialize)过程,无法正确识别集合中子元素的字符串类型。而PHPRPC中,负责序列化与反序列化过程的类为PHPSerializer.java。所以定位好问题后就不难解决了。此处省略N千字,其实也就是添加一行代码的问题,却耗尽了一整个下午的精力。以下是编译好了的spring2.5需要用到phprpc的三个jar 文件,分别是:phprpc_client.jar phprpc_spring.jar phprpc.jar。
下载便能用。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!