java - 带有 GWT 的 POJO 库

标签 java gwt

我有一个运行良好的 GWT 项目,并且我使用了一堆共享类。在项目的这个阶段,我需要与其他库共享 POJO。

我决定将 POJO 放入库中。

public class Application implements IsSerializable {
    // ....
}

由于这个库是技术中立的,我想摆脱 IsSerialized 和对 GWT 的依赖。这有道理吗?

我需要在项目的 GWT 方面做任何事情吗?

最佳答案

您可以使用标准的java.io.Serialized接口(interface)来代替(现在有些过时的)IsSerialized。引入它的原因是为了将 GWT RPC 序列化与 Java 序列化区分开来。来自 official FAQ entry关于这个主题:

  • The semantics of GWT's serialization are much less sophisticated than standard Java serialization, and so to use java.io.Serializable as the marker interface would imply that GWT's serialization system is capable of more than it actually is.
  • Conversely, GWT's serialization mechanism is simpler than standard Java's, and so to use java.io.Serializable would imply that users have more to worry about (such as serialization version IDs) than they actually do.
  • GWT implements only a subset of the full Java JRE classes, and specifically implements nothing in java.io. To use java.io.Serializable as the GWT RPC serialization marker interface dilutes the message that java.io is not usable within a GWT application.

While each of the points above still hold, 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 (...).

关于java - 带有 GWT 的 POJO 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23996217/

相关文章:

java - 哪些类必须实现 Serializable 接口(interface)?

java - 无法运行已编译的java类,错误: Class names are only accepted if annotation processing is explicitly requested

java - 如何在 JPanel 中添加 JButton?

javascript - 从 GWT 中的 HighCharts 库中以编程方式在股票图表上选择一个点(也在 native JS 中)

javascript - 查看 GWT 应用程序的所有 javascript 变量

css - 在 CSS 属性中访问 GWT ImageResource?

java - 调整 GXT 网格大小

java - JFreeChart:如何获得十字准线指向的确切 XYDataItem 实例?

java - 在 Dos 命令提示符中检查 Scala 的当前版本

gwt - 是否可以在 NodeJS 中托管 GWT 编译的 Web 应用程序?