简体   繁体   English

带GWT的POJO库

[英]POJO library with GWT

I have a GWT project which is running fine and I use a bunch of shared classes. 我有一个运行良好的GWT项目,并且使用了一堆共享类。 At this stage of the project, I need to share the POJOs with other library. 在项目的这个阶段,我需要与其他库共享POJO。

I decided to put the POJO in a library. 我决定将POJO放在一个库中。

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

As this library is technology neutral, i would like to get rid of the IsSerializable and the dependency to GWT. 由于该库是技术中立的,因此我想摆脱IsSerializable和对GWT的依赖。 Does that make sense? 那有意义吗?

Do I need to do anything on the GWT side of the project? 我是否需要在项目的GWT方面做任何事情?

You can use the standard java.io.Serializable interface instead of the (now somewhat obsolete) IsSerializable . 您可以使用标准的java.io.Serializable接口代替(现在已经过时) IsSerializable The reason it was introduced was to distinguish GWT RPC serialization from the Java's one. 引入它的原因是为了区分GWT RPC序列化和Java的序列化。 From the official FAQ entry on this subject: 从有关此主题的官方常见问题解答条目中

  • 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. GWT序列化的语义比标准Java序列化的复杂程度低得多,因此使用java.io.Serializable作为标记接口将意味着GWT的序列化系统具有比实际能力更多的功能。
  • 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的序列化机制比标准Java更为简单,因此使用java.io.Serializable意味着用户比实际需要担心的更多(例如序列化版本ID)。
  • GWT implements only a subset of the full Java JRE classes, and specifically implements nothing in java.io . GWT仅实现完整的Java JRE类的子集,并且在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. 要将java.io.Serializable用作GWT RPC序列化标记接口,将稀释java.io在GWT应用程序中不可用的消息。

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 (...). 尽管以上各点仍然成立,但是GWT团队认为社区通常已经意识到了这些问题,但是更喜欢使用标准java.io.Serializable接口而不是让其类实现IsSerializable标记接口的IsSerializable (......)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM