Hi. Can you give us a simple example of using gwt-rpc-plus?

5 views
Skip to first unread message

Yesudeep Mangalapilly

unread,
Jan 5, 2010, 10:04:44 AM1/5/10
to DotSpots Open Source
I'd really appreciate reading through simple examples of using gwt-rpc-
plus
to learn to use it properly. Could you please provide us with a
simple tutorial
using the example?

Thanks.

Matt Mastracci (DotSpots)

unread,
Jan 5, 2010, 3:16:03 PM1/5/10
to DotSpots Open Source
Hi Yesudeep,

Sure, that would be possible to do. Are you looking to run standard
GWT RPC over a cross-domain transport, or replace it entirely with
Thrift? I can focus tutorial efforts on whichever is most needed.

Yesudeep

unread,
Jan 5, 2010, 3:23:34 PM1/5/10
to dotspots-o...@googlegroups.com
We have backends other than Java in production and GWT RPC 
seems to be limited to Java on both ends (client and server).  
We'd personally like to be able to use something that doesn't tie us 
to Java on the server even when we're using GWT for the client.  
A tutorial on replacing GWT RPC entirely with Thrift would, I hope, 
help those of us who cannot use GWT RPC.

Thank you very much for responding so quickly! 

--
Cheers,
Yesudeep Mangalapilly | येसुदीप मंगलािपल्ली
GnuPG: 0x79E237CB | IRC: jburd

Matt Mastracci

unread,
Jan 5, 2010, 3:25:48 PM1/5/10
to dotspots-o...@googlegroups.com
On 2010-01-05, at 1:23 PM, Yesudeep wrote:

On Wed, Jan 6, 2010 at 1:46 AM, Matt Mastracci (DotSpots) <mat...@dotspots.com> wrote:
Hi Yesudeep,

Sure, that would be possible to do. Are you looking to run standard
GWT RPC over a cross-domain transport, or replace it entirely with
Thrift? I can focus tutorial efforts on whichever is most needed.

We have backends other than Java in production and GWT RPC 
seems to be limited to Java on both ends (client and server).  
We'd personally like to be able to use something that doesn't tie us 
to Java on the server even when we're using GWT for the client.  
A tutorial on replacing GWT RPC entirely with Thrift would, I hope, 
help those of us who cannot use GWT RPC.

OK, great. I'll put that on my to-do list and ping you when I've had a chance to whip it up.

Thanks for the feedback,


mstead

unread,
Mar 1, 2010, 8:34:27 AM3/1/10
to DotSpots Open Source
Hi Matt:

I'm interested in this same type of tutorial. ave you had a chance to
put this together?

I'd be interested in seeing how to replace the GWT RPC mechanism with
Thrift using gwt-rpc-plus,

Also, what version of GWT is supported?

Thanks.

On Jan 5, 4:25 pm, Matt Mastracci <matt...@dotspots.com> wrote:
> On 2010-01-05, at 1:23 PM, Yesudeep wrote:
>

> > On Wed, Jan 6, 2010 at 1:46 AM, Matt Mastracci (DotSpots) <matt...@dotspots.com> wrote:
> > Hi Yesudeep,
>
> > Sure, that would be possible to do. Are you looking to run standard
> > GWT RPC over a cross-domain transport, or replace it entirely with
> > Thrift? I can focus tutorial efforts on whichever is most needed.
>
> > We have backends other than Java in production and GWT RPC
> > seems to be limited to Java on both ends (client and server).  
> > We'd personally like to be able to use something that doesn't tie us
> > to Java on the server even when we're using GWT for the client.  
> > A tutorial on replacing GWT RPC entirely with Thrift would, I hope,
> > help those of us who cannot use GWT RPC.
>
> OK, great. I'll put that on my to-do list and ping you when I've had a chance to whip it up.
>
> Thanks for the feedback,
>
> Matt Mastracci

> matt...@dotspots.com
>
> http://dotspots.com

Matt Mastracci

unread,
Mar 1, 2010, 11:47:47 AM3/1/10
to dotspots-o...@googlegroups.com
Hi Mike,

Unfortunately things have been pretty hectic and I haven't had a chance to put this together. I'll try to quickly braindump some documentation here and eventually get it into Wiki form. We're currently using this framework in production, but there are definitely places we'd like to improve the API and experience.

There's some preliminary information on compiling the Thrift interfaces here: http://code.google.com/p/gwt-rpc-plus/wiki/GettingStartedWithThrift

The server-side Thrift APIs requires three pieces:

1. an API implementation that implements the server-side piece of the Thrift interface (see com.dotspots.rpcplus.example.jsonrpc.thrift.ExampleService)
2. a set of JSON-processing stubs that convert the incoming JSON into equivalent Thrift calls (autogenerated from the Thrift IDL for you)
3. a thin servlet that dispatches events to the JSON-processing stubs. This is kept separate from the API implementation to more easily integrate with frameworks like Spring/Guice/etc.

Here's an example of the dispatching servlet, written using Spring-style web handlers. Note that we're just passing the incoming request directly into the ThriftRequestProcessor. This class extracts the JSON payload from the request and passes it into the JSON-processing stub. The stub then determines the correct method to call, dispatches the call and re-serializes the return value.

public class MyApiHandler implements HttpRequestHandler {
private ThriftRequestProcessor thriftRequestProcessor;

private MyApiJson myApiJson;

@Autowired
MyApiImpl myApiImpl;

@PostConstruct
public void postConstruct() {
thriftRequestProcessor = new ThriftRequestProcessor();
myApiJson = new MyApiJson();
myApiJson.setService(myApiImpl);
}

@Override
public void handleRequest(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
thriftRequestProcessor.handleRequest(myApiJson, req, resp);
}
}

Matt Mastracci
mat...@dotspots.com

http://dotspots.com

mstead

unread,
Mar 1, 2010, 1:26:17 PM3/1/10
to DotSpots Open Source
Thanks for the info Matt. Greatly appreciated.

With this framework, is it possible to have a GWT client stand-alone?
For example, start a Python Thrift server on some port, and have my
GWT client make requests to it. I don't want to have to go through a
servlet that sits in between the GWT client and the Python Thrift
server.

--
Mike

> matt...@dotspots.com
>
> http://dotspots.com

Matt Mastracci

unread,
Mar 1, 2010, 2:31:03 PM3/1/10
to dotspots-o...@googlegroups.com
It's possible, but you'll need to send the appropriate style JSON to the client. This client doesn't use standard Thrift JSON, but rather a form of JSON optimized for native processing in Javascript. This custom JSON format allows the RPC objects to be JSNI-based which the compiler optimizes away to JSON.parse/stringify and simple array access.

Bog standard Thrift JSON embeds Thrift types in the JSON data that make it difficult to use efficiently on the client. I'm not familiar with the Python version of Thrift, but it's likely you might have to write a shim to read/write this form of JSON if you want to use this library.

Matt Mastracci
mat...@dotspots.com

http://dotspots.com

Reply all
Reply to author
Forward
0 new messages