繁体   English   中英

为什么GWT RPC需要同步接口?

[英]Why do you need synchronous interface for GWT RPC?

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

我看不到使用synchornous接口的地方!

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

从文档中:

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。 您必须创建一个异步

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM