gpt4 book ai didi

java - 在 GWT 中既可序列化又可 IsSerializable

转载 作者:行者123 更新时间:2023-11-30 11:51:15 24 4
gpt4 key购买 nike

我在一个独立于我的 GWT 项目的项目中有一些 DTO,我正在尝试将它们用作 GWT 项目中的 DTO。它们实现了 Serializable 以便与其他服务一起使用。目前,因为我不希望在 GWT RPC 服务接口(interface)方法签名中引用它们,所以我必须采用“欺骗”GWT 的技术,通过制作不执行任何操作且从不调用的虚拟方法将类列入白名单以进行序列化。

我不想在 GWT 项目中创建单独的 IsSerializable 类以避免重复代码,但虚拟方法也不可取。

我想到的一种替代方法是添加 (a) GWT jar 作为包含我的 DTO 的项目的依赖项,以便它们可以同时实现 SerializableIsSerializable。对同时是 SerializableIsSerializable 的主题的搜索只会引发关于在两者之间进行选择的讨论。

一个类能否同时实现 SerializableIsSerializable 而不会出现复杂情况?

最佳答案

您使用的是哪个版本的 GWT?如果它是最近的(> 1.4),那么据我所知,GWT documentation说你可以直接使用你的 Serializable 对象:

the GWT Team felt that the community was generally aware of these issues but preferred the convenience of being able to use the standard java.io.Serializable interface rather than to have their classes implement the isSerializable marker interface, although both marker interfaces to denote serializable classes are supported in GWT 1.4 and later. Considering this, the GWT Team made changes to the GWT RPC system to support the use of java.io.Serializable for data transfer objects (commonly referred to as DTOs) that would be transferred over the wire. However, there is one condition to enable support for java.io.Serializable in the new GWT RPC system.

关于java - 在 GWT 中既可序列化又可 IsSerializable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7570500/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com