GWT中的IsSerializable接口的目的是什么(关于RPC机制) [英] What is the purpose of the IsSerializable interface in GWT (regarding the RPC mechanism)

查看:149
本文介绍了GWT中的IsSerializable接口的目的是什么(关于RPC机制)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GWT中的IsSerializable接口的用途是什么(关于RPC机制)。我从来没有找到一个很好的解释,为什么它是这样,以及为什么默认的Java Serializable标记接口不起作用。

What is the purpose of the IsSerializable interface in GWT (regarding the RPC mechanism). I have never been able to find a good explanation as to why it is the way it is and why the default Java Serializable tagging interface does not work.

推荐答案

根据 IsSerializable code.google.com/webtoolkit/doc/latest/DevGuideServerCommunication.html#DevGuideSerializableTypesrel =noreferrer> GWT序列化文档

Both Serializable and IsSerializable work, according to the GWT serialization docs:


如果以下所有条件都适用,则用户定义的类是可序列化的:

A user-defined class is serializable if all of the following apply:


  1. 可分配给IsSerializable或Serializable,它直接实现了其中的一个接口,或者它是从一个超类派生而来的
  2. 所有非最终的,非暂时的实例字段本身都是可序列化的,并且
  3. 从GWT 1.5开始,它必须有一个默认的(零参数)构造函数(带有任何访问修饰符)或根本就没有构造函数。


不过,出于安全原因,所有 Serializable 类必须包含在一个序列化策略,它在编译时生成,而 IsSerializable 类没有这个要求。

One key difference though is that , for security reasons, all Serializable classes must be included in a serialization policy, which is generated at compile time, while IsSerializable classes do not have that requirement.

如果你的兴趣纯粹在GWT中,并且你不需要在Web应用程序和另一个应用程序之间共享你的模型类,我建议你让你的模型类/ DTO实现 IsSerializable code>。

If your interest is purely in GWT, and you don't e.g. share your model classes between the web application and another application, I suggest you have your model classes/DTOs implement IsSerializable.

这篇关于GWT中的IsSerializable接口的目的是什么(关于RPC机制)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆