【问题标题】:GWT RPC client sequence before sending Request发送请求前的 GWT RPC 客户端序列
【发布时间】:2010-11-04 13:21:14
【问题描述】:

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

现在,我没有在 ClientSerializationStreamWriter(here) 类中找到调用以下方法的方法调用序列:

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

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

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

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

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

谢谢。

朱达克

【问题讨论】:

    标签: gwt request rpc


    【解决方案1】:

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

    关于您的其他问题:

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

    /com/google/gwt/rpc/RPC.gwt.xml (gwt-user.jar) 为您的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;
    }
    

    【讨论】:

      【解决方案2】:

      我找到了我的问题的可能答案。在类 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
      

      HTH

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-11-03
        相关资源
        最近更新 更多