search
HomeBackend DevelopmentPHP TutorialPHPRPC 3.0.2 for Java 中加强了对容器接口的支持

PHPRPC 3.0.2 for Java 中增强了对容器接口的支持
PHPRPC for Java 在 3.0.2 之前,对容器接口还不提供支持,比如发布方法的参数类型和返回值不能声明为 List、Map 等接口类型,客户端的代理接口也不行。

而在 3.0.2 中,已经没有这个限制了,不管是参数类型还是返回值类型都可以声明为 List、Map、Set、Collection 这四种容器类型。当用这些接口类型接收数据时,List、Collection 会被转换成 ArrayList 类型,Set 会被转换成 HashSet 类型,Map 会被转成 HashMap 类型。另外,自定义类型如果继承自某个接口类型,同样可以使用接口类型来声明这样的参数和返回值。因此,你原来已有的业务逻辑代码在不需要任何修改的情况下,就可以作为 PHPRPC 服务进行发布了!

1 楼 long13168 2009-12-08  
public interface AuthoritiesManager {	public Map<string> getUrlAuthorities(String packCode);}public class AuthoritiesManagerImpl implements AuthoritiesManager {		public Map<string> getUrlAuthorities(String packCode) {		Map<string string> urlAuthorities = new HashMap<string string>();		urlAuthorities.put("/index.gm*", "ROLE_USER");		return urlAuthorities;	}}</string></string></string></string>


请问andot大哥,为何我用phprpc_spring得到调用getUrlAuthorities时返回的map字符串有问题,是一串像是引用地址的东西。
正常应是/index.gm*=ROLE_USER,但它返回/index.gm*=[[email protected]
百思不得其解,不是面向接口的话会自动转换类型吗?

2 楼 andot 2009-12-08  
PHPRPC 在处理字符串时,是按照字节数组处理的,所以不能用 Map这样的泛型(Java中这种泛型在执行时得不到里面的类型,所以没法正确转换),所以Map中的key虽然是String,但是value却是byte[]的,所以你看到的是[[email protected] 这样东西。这个在PHPRPC中需要自己坐一下转换。

如果觉得麻烦,可以使用 PHPRPC 的商业版 hprose,hprose 的字符串和字节数组是分开的,所以不存在这个问题。而且执行效率比 PHPRPC 高 10 倍,易用程度和灵活性也大大改善了。

3 楼 long13168 2009-12-08  
PHPRPC 3.0.2 for Java 中加强了对容器接口的支持
谢谢andot解答
暂时未考虑商业应用,目前是先做demo给老板们看看,让他们感受下phprpc的力量啦

4 楼 GRDJE 2009-12-08  
又在广告吧。。。。。

5 楼 mathgl 2009-12-09  
hprose...现在开发的怎么样了。早些时候看过 一下网站,除了价钱啥都没有。

6 楼 andot 2009-12-09  
mathgl 写道
hprose...现在开发的怎么样了。早些时候看过 一下网站,除了价钱啥都没有。

我们已经发布了1.0了,现在已经开卖了。PHPRPC 3.0.2 for Java 中加强了对容器接口的支持

这里还有手册样章:
http://www.hprfc.com/doc/java.pdf

7 楼 andot 2009-12-09  
GRDJE 写道
又在广告吧。。。。。

我只是在回答问题而已,你见过这么低调的广告吗?PHPRPC 3.0.2 for Java 中加强了对容器接口的支持 呵呵。
Statement
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
Explain how load balancing affects session management and how to address it.Explain how load balancing affects session management and how to address it.Apr 29, 2025 am 12:42 AM

Load balancing affects session management, but can be resolved with session replication, session stickiness, and centralized session storage. 1. Session Replication Copy session data between servers. 2. Session stickiness directs user requests to the same server. 3. Centralized session storage uses independent servers such as Redis to store session data to ensure data sharing.

Explain the concept of session locking.Explain the concept of session locking.Apr 29, 2025 am 12:39 AM

Sessionlockingisatechniqueusedtoensureauser'ssessionremainsexclusivetooneuseratatime.Itiscrucialforpreventingdatacorruptionandsecuritybreachesinmulti-userapplications.Sessionlockingisimplementedusingserver-sidelockingmechanisms,suchasReentrantLockinJ

Are there any alternatives to PHP sessions?Are there any alternatives to PHP sessions?Apr 29, 2025 am 12:36 AM

Alternatives to PHP sessions include Cookies, Token-based Authentication, Database-based Sessions, and Redis/Memcached. 1.Cookies manage sessions by storing data on the client, which is simple but low in security. 2.Token-based Authentication uses tokens to verify users, which is highly secure but requires additional logic. 3.Database-basedSessions stores data in the database, which has good scalability but may affect performance. 4. Redis/Memcached uses distributed cache to improve performance and scalability, but requires additional matching

Define the term 'session hijacking' in the context of PHP.Define the term 'session hijacking' in the context of PHP.Apr 29, 2025 am 12:33 AM

Sessionhijacking refers to an attacker impersonating a user by obtaining the user's sessionID. Prevention methods include: 1) encrypting communication using HTTPS; 2) verifying the source of the sessionID; 3) using a secure sessionID generation algorithm; 4) regularly updating the sessionID.

What is the full form of PHP?What is the full form of PHP?Apr 28, 2025 pm 04:58 PM

The article discusses PHP, detailing its full form, main uses in web development, comparison with Python and Java, and its ease of learning for beginners.

How does PHP handle form data?How does PHP handle form data?Apr 28, 2025 pm 04:57 PM

PHP handles form data using $\_POST and $\_GET superglobals, with security ensured through validation, sanitization, and secure database interactions.

What is the difference between PHP and ASP.NET?What is the difference between PHP and ASP.NET?Apr 28, 2025 pm 04:56 PM

The article compares PHP and ASP.NET, focusing on their suitability for large-scale web applications, performance differences, and security features. Both are viable for large projects, but PHP is open-source and platform-independent, while ASP.NET,

Is PHP a case-sensitive language?Is PHP a case-sensitive language?Apr 28, 2025 pm 04:55 PM

PHP's case sensitivity varies: functions are insensitive, while variables and classes are sensitive. Best practices include consistent naming and using case-insensitive functions for comparisons.

See all articles

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

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.