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

查看:17
本文介绍了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.

推荐答案

SerializableIsSerializable 都可以工作,根据 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.

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天全站免登陆