Home Backend Development PHP Tutorial 批改phprpc源码以支持集合类的string类型的转换

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

Jun 13, 2016 am 10:39 AM
char jar string

修改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。
下载便能用。

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to run jar files in Linux How to run jar files in Linux Feb 20, 2024 am 10:40 AM

Prerequisites for running JAR files Running JAR files on a Linux system requires the installation of the Java Runtime Environment (JRE), which is the basic component required to execute Java applications, including the Java Virtual Machine (JVM), core class libraries, etc. Many mainstream Linux distributions, such as Ubuntu, Debian, Fedora, openSUSE, etc., provide software libraries of JRE packages to facilitate user installation. The following article will detail the steps to install JRE on popular distributions. After setting up the JRE, you can choose to use the command line terminal or the graphical user interface to start the JAR file according to your personal preference. Your choice may depend on familiarity with Linux shells and personal preference

How docker deploys SpringBoot and replaces jar packages How docker deploys SpringBoot and replaces jar packages May 12, 2023 pm 02:16 PM

Create a dockerfile file in the project directory dockerfile, which will be used later. The file is deployed in the newly created /data/docker/hellolearn folder on the server (the file path can be customized). Copy the maven packaged jar package and the dockerfile file created above to the newly created folder on the server (/data/docker/hellolearn). . Generate the image dockerbuild-thellolearn.dockerbuild-t Image name: the relative position of the label dockerfile, the dot represents the current directory, and the default is latest if no tag is written. Start container doc

How to package springboot into a jar package in maven How to package springboot into a jar package in maven May 17, 2023 am 08:19 AM

maven command: 1.mvncleanpackage-DskipTests: Run this command in the project directory to generate a jar package or war package in the target directory. 2.mvnclean: Clean the temporary files produced by the project, usually the target directory under the module 3.mvncompile-DskipTests: The module installation command copies the packaged jar/war file to your local warehouse for use by other modules -Dmaven. test.skip=true skips testing (testcompile will also be skipped).4.mvntest: test command, or execute src/test/java/

Convert basic data types to strings using Java's String.valueOf() function Convert basic data types to strings using Java's String.valueOf() function Jul 24, 2023 pm 07:55 PM

Convert basic data types to strings using Java's String.valueOf() function In Java development, when we need to convert basic data types to strings, a common method is to use the valueOf() function of the String class. This function can accept parameters of basic data types and return the corresponding string representation. In this article, we will explore how to use the String.valueOf() function for basic data type conversions and provide some code examples to

How to convert char array to string How to convert char array to string Jun 09, 2023 am 10:04 AM

Method of converting char array to string: It can be achieved by assignment. Use {char a[]=" abc d\0efg ";string s=a;} syntax to let the char array directly assign a value to string, and execute the code to complete the conversion.

How to start, stop and restart the springboot jar package in Linux How to start, stop and restart the springboot jar package in Linux May 14, 2023 am 09:37 AM

Foreword In the configuration file of springboot, the names of the configuration files have their own meanings and uses. dev development environment prod production environment (default) test test environment loads the specified configuration file--spring.profiles.active=prod The ways for springboot to load jar packages are/ /Start directly in the console. The disadvantage is that the project will be closed when the console is closed. java-jarbootdo.jar//This method can run in the background, but if the shell is launched, it will also hang java-jar/bootdo-2.0.0.jar>bootdolog.file2>&

How does SpringBoot hang the configuration file outside the jar package? How does SpringBoot hang the configuration file outside the jar package? May 15, 2023 pm 03:01 PM

1. SpringBoot specifies the configuration file path: In SpringBoot, the configuration file can be placed outside the jar package, so that the configuration can be easily modified without repackaging and deployment. The following are several ways to specify the configuration file directory: (sorted from high to low effectiveness priority) 1) Use command line parameters: When starting the application, you can use --spring.config.location or -Dspring.config. The location command line parameter specifies the path to the configuration file, for example: (the / after config cannot be omitted) java-jartest.jar--spring.config.locatio

How does SpringBoot delete useless beans in referenced jar packages? How does SpringBoot delete useless beans in referenced jar packages? May 14, 2023 pm 08:07 PM

Preface: The company has a project that is in a hurry, and some of the project's requirements are the same as some of the functions of previous projects. In order to speed up and directly introduce some modules in the previous multi-module maven project in the form of jar packages. The new project was launched. Although it saved a lot of development time, it also caused the project to need to import the related dependencies of the project jar, causing the project to be bloated and slow to start. Is there a way to make the project load only the beans it needs? Of course, we can directly modify the source code and repackage it to solve the problem, but this method is too troublesome. Through Baidu's method, the query can use the @ComponentScan annotation on the springboot startup class to implement the code example @Componen

See all articles