从Java对象生成GWT覆盖类型 [英] Generate GWT Overlay types from Java objects

查看:100
本文介绍了从Java对象生成GWT覆盖类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我们正在GWT项目中使用GWT RPC进行序列化,但我们目前正在维护两组对象 - 我们需要为数据库转换以检索/保存的对象以及一个安全对象的版本对于GWT RPC序列化(不枚举/大数小数等)。

我们花费大量精力编写仅从一种格式转换为另一种格式的代码。此外,对数据模型进行任何更改都是非常痛苦的,因为它必须在两处进行更改。



我想我们可以使用 Spring 3.0 MVC和Jackson 将取代带有JSON调用的RPC调用。如果我们为GWT构建的JavaScript对象来保存此内容JSON数据,那么它将消除对任何属性转换代码的需求。但是,我们仍然需要维护两组对象 - 一个用于客户端代码的JavaScriptObject和一个服务器端表示。



为了消除这个层,需要一个Java对象并让它产生一个带有JSNI getters / setters的GWT JavaScriptObject。是否有一个库可以自动执行此操作?

解决方案

我们最终放弃了GWT并使用了Spring MVC / jQuery解决方案,但我确实找到了 protostuff库,看起来它可以完成我期待的大部分内容为。


We're currently using GWT RPC for serialization on a GWT project but we're currently maintaining two sets of objects - the object that we need to convert for the database to retrieve/save and a version of the object that is safe for GWT RPC serialization (no enums/big decimal, etc.).

We're spending a lot of effort writing code that merely converts from one format to the other format. In addition it's pretty painful to make any changes to the data model because it has to be changed in two places.

I was thinking that we could use a combination of Spring 3.0 MVC and Jackson to replace the RPC calls with JSON calls. If we built JavaScript objects for GWT to hold this JSON data, then it would remove the need for any property conversion code. However we'd still have to maintain two sets of objects - one JavaScriptObject for the client side code and the server side representation.

To eliminate this layer, to take a Java object and have it produce a GWT JavaScriptObject with the JSNI getters/setters exposed. Is there a library out there that could do this automatically?

解决方案

We eventually dropped GWT and went with a Spring MVC/jQuery solution, but I did find the protostuff library which looked like it could do most of what I was looking for.

这篇关于从Java对象生成GWT覆盖类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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