是否可以在不使用RPC序列化的情况下使用面向GWT RPC的命令模式?

时间:2022-02-27 21:35:19

In the process of refactoring the client-serverside communication of out GWT-based framework I came across discussions concerning the possible elimination of RPC in GWT 3.0+

在重构基于GWT的框架的客户端 - 服务器端通信的过程中,我遇到了关于可能在GWT 3.0+中消除RPC的讨论

Our framework is currently based on the RPC-oriented Command Pattern. At the moment I'm wondering on how it would be possible to get rid of RPC without changing the business code fundamentally.

我们的框架目前基于面向RPC的命令模式。目前我想知道如何在不从根本上改变业务代码的情况下摆脱RPC。

My first approach was to use JSON for serialization/deserialization of Action and Result. But at least on client side methods fromJsonString() and toJsonString() need to be implemented manually because there is no reflection on client side. After reading about JSInterop which was introduced with GWT 2.7 I wondered if there maybe is a better way to serialize/deserialize the Action and Result on clientside as well as on serverside.

我的第一种方法是使用JSON进行Action和Result的序列化/反序列化。但至少在客户端方法fromJsonString()和toJsonString()需要手动实现,因为客户端没有反射。在阅读了GWT 2.7引入的JSInterop之后,我想知道是否有更好的方法可以在客户端和服务器端序列化/反序列化Action和Result。

Unfortunately I'm a bit stuck right now. Are there already approaches to implement the command pattern without RPC?

不幸的是我现在有点卡住了。是否已经有方法在没有RPC的情况下实现命令模式?

Best regards

1 个解决方案

#1


1  

I wouldn't worry to much about possible elimination of RPC at this moment (2016). Given the current speed of the GWT releases it might take some time before we see version 3 and even then the elimination of RPC is not a sure thing. So from a priority point of view there is no reason to put much effort in it.

我现在不担心可能消除RPC(2016)。鉴于当前GWT版本的发布速度,我们可能需要一些时间才能看到版本3,即使这样,RPC的消除也不是肯定的。因此,从优先考虑的角度来看,没有理由在其中付出太多努力。

A past RPC future would very likely be based on JSON. Where the json code is generated from the Java classes. There are some libraries to do this. For example look at gwtjsonrpc. It uses the json-rpc (as the name already suggest). You could use it as a command pattern, but it's not a direct implementation of the command pattern.

过去的RPC未来很可能基于JSON。 json代码是从Java类生成的。有一些库可以做到这一点。例如,看看gwtjsonrpc。它使用json-rpc(顾名思义)。您可以将它用作命令模式,但它不是命令模式的直接实现。

#1


1  

I wouldn't worry to much about possible elimination of RPC at this moment (2016). Given the current speed of the GWT releases it might take some time before we see version 3 and even then the elimination of RPC is not a sure thing. So from a priority point of view there is no reason to put much effort in it.

我现在不担心可能消除RPC(2016)。鉴于当前GWT版本的发布速度,我们可能需要一些时间才能看到版本3,即使这样,RPC的消除也不是肯定的。因此,从优先考虑的角度来看,没有理由在其中付出太多努力。

A past RPC future would very likely be based on JSON. Where the json code is generated from the Java classes. There are some libraries to do this. For example look at gwtjsonrpc. It uses the json-rpc (as the name already suggest). You could use it as a command pattern, but it's not a direct implementation of the command pattern.

过去的RPC未来很可能基于JSON。 json代码是从Java类生成的。有一些库可以做到这一点。例如,看看gwtjsonrpc。它使用json-rpc(顾名思义)。您可以将它用作命令模式,但它不是命令模式的直接实现。