为什么 GWT RPC 需要同步接口



我想知道为什么在使用 GWT RPC 时还需要定义同步接口,因为所有调用都是异步的 (http://www.gwtproject.org/doc/latest/DevGuideServerCommunication.html)?

我没有看到同步接口在哪里使用!

即为什么我们不能在我们的服务实现类中实现同步接口?

从文档中:

http://www.gwtproject.org/doc/latest/DevGuideServerCommunication.html#DevGuideCreatingServices

此同步接口是服务规范的最终版本。此服务在服务器端的任何实现都必须扩展 RemoteServiceServlet 并实现此服务接口。

package com.example.foo.server;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.example.client.MyService;

public class MyServiceImpl extends RemoteServiceServlet implements
    MyService {
  public String myMethod(String s) {
    // Do something interesting with 's' here on the server.
    return s;
  }
}

提示: 无法直接从客户端调用此版本的 RPC。您必须创建异步

最新更新