开发者

Gwt need to create Async and Sync interfaces for RPC request

what is the need to create Async and Sync interface in 开发者_StackOverflowclient package and its impl class in Server package when need to impelement RPC in GWT. What is the need to create Sync as well as Async interface in GWT for successful RPC.


In a nutshell: Async is needed for client side, Sync is needed for server side.

All RPC (XmlHttpRequest) calls in Javascript are asynchronous - when network call is finished, your code is called with result.

So on client side with GWT RPC you must provide an Async interface (and implementation of it) in order to be called when results are available.

You must also provide related Sync interface which is implemented on server side.

There is a contract on how Async and Sync interface must be written: http://code.google.com/webtoolkit/doc/latest/tutorial/RPC.html


well I assume that you know that any JS in browser is kind of synchronous event driven. To responce to the RPC you need a callback. So when writing Java code you need to pass the callback object to a call. but the server side is a simple method call with return type that should match the parameter of the callback. Right?

So here you get 2 interfaces that all together give you full type safety at compile time. and allows it all work smooth as it does.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜