发送请求之前的 GWT RPC 客户端序列

发布于 2024-10-01 03:09:54 字数 921 浏览 2 评论 0原文

我提出了上一个问题,寻找在 RPC 调用上构建内容的类(here )。

现在,我没有找到导致调用类 ClientSerializationStreamWriter(此处):

@Override
public String toString() {
    StringBuffer buffer = new StringBuffer();
    writeHeader(buffer);
    writeStringTable(buffer);
    writePayload(buffer);
    return buffer.toString();
}

我注意到 ClientSerializationStreamWriter 在 RemoteServiceProxy 中使用,并且该类在 RpcServiceProxy 上进行了扩展。我试图找到的是在发送之前构建请求的确切点。 RemoteServiceProxy 中的 doInvoke 方法似乎负责调度请求本身,但是 String requestData 是如何构建的?

com.google.gwt.user.client.rpc.impl.RemoteServiceProxy.doInvoke

我想了解 RPC 请求在离开客户端 Web 浏览器之前执行的常规路径。到目前为止我还不确定每个 RPC 都使用 RpcServiceProxy。

我有很多假设,但没有断言。

谢谢。

聚达克

I've made a previous question, looking for the class that build the content on a RPC call(here).

Now, I'm not finding the sequence of method calls that results on the call of the following method in the class ClientSerializationStreamWriter(here):

@Override
public String toString() {
    StringBuffer buffer = new StringBuffer();
    writeHeader(buffer);
    writeStringTable(buffer);
    writePayload(buffer);
    return buffer.toString();
}

I noticed that the ClientSerializationStreamWriter is used in RemoteServiceProxy and that, this class is extended on RpcServiceProxy. What I'm trying to find is the exactly point where the request is build before the send.
The method doInvoke from RemoteServiceProxy seems to be responsible for dispatching the request itself, but how the String requestData is build?

com.google.gwt.user.client.rpc.impl.RemoteServiceProxy.doInvoke

I want to understand the regular path a RPC request does before it leaves clients web browser. So far I'm not sure that every RPC uses RpcServiceProxy.

I have a lot of assumptions and none assertion.

Thanks.

JuDaC

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

画骨成沙 2024-10-08 03:09:54

也许了解有关调用堆栈的更多信息的最佳方法是使用 Java 调试器(这在开发模式下是可能的 - 即使对于客户端代码也是如此!)

关于您的其他问题:

到目前为止我还不确定每个 RPC 都使用 RpcServiceProxy。

/com/google/gwt/rpc/RPC.gwt.xml (gwt-user.jar) 为您的 RemoteService 指定延迟绑定:

<generate-with class="com.google.gwt.rpc.rebind.RpcServiceGenerator">
  ...
  <when-type-assignable class="com.google.gwt.user.client.rpc.RemoteService" />
  ...
</generate-with>

RpcServiceGenerator:

protected ProxyCreator createProxyCreator(JClassType remoteService) {
  return new RpcProxyCreator(remoteService);
}

RpcProxyCreator:

protected Class<? extends RemoteServiceProxy> getProxySupertype() {
  return RpcServiceProxy.class;
}

Maybe the best way to find out more about the call stack is by using a Java Debugger (that's possible in Development Mode - even for the client side code!)

About your other question:

So far I'm not sure that every RPC uses RpcServiceProxy.

/com/google/gwt/rpc/RPC.gwt.xml (gwt-user.jar) specifies a deferred binding for your RemoteServices:

<generate-with class="com.google.gwt.rpc.rebind.RpcServiceGenerator">
  ...
  <when-type-assignable class="com.google.gwt.user.client.rpc.RemoteService" />
  ...
</generate-with>

RpcServiceGenerator:

protected ProxyCreator createProxyCreator(JClassType remoteService) {
  return new RpcProxyCreator(remoteService);
}

RpcProxyCreator:

protected Class<? extends RemoteServiceProxy> getProxySupertype() {
  return RpcServiceProxy.class;
}
窗影残 2024-10-08 03:09:54

我找到了我的问题的可能答案。在类 ProxyCreator 行中:479。

String payloadName = nameFactory.createName("payload");
w.println("String " + payloadName + " = " + streamWriterName
    + ".toString();");

在创建我的服务期间,

private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);

GWT 编译器动态生成 RPC 代理,此时 GWT 编译器注入代理方法(ProxyCreator.generateProxyMethod)。

com.google.gwt.user.rebind.rpc.ProxyCreator.generateProxyMethod

华泰

I found the probably answer to my question. In the Class ProxyCreator line: 479.

String payloadName = nameFactory.createName("payload");
w.println("String " + payloadName + " = " + streamWriterName
    + ".toString();");

During the creation of my service

private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);

GWT compiler generates dynamically the RPC proxy, in this moment GWT compiler inject the proxy method (ProxyCreator.generateProxyMethod).

com.google.gwt.user.rebind.rpc.ProxyCreator.generateProxyMethod

HTH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文