using new 2.1.1rc RequestFactory AutoBean in RESTful Architecture

208 views
Skip to first unread message

zixzigma

unread,
Dec 11, 2010, 5:01:28 PM12/11/10
to Google Web Toolkit
is it possible to use 2.1.1 RequestFactory/AutoBean to convert POJO to
JSON and viceversa
when interacting with a RESTful Web Service ?

the common practice with GWT client-server communication is
to have packages:
client, shared, server, configuring web.xml

however, in-order to be truly loosely coupled,
I am thinking of developing the Server side of my app,
as a REST WebService. completely separate from the client.
sending JSON encoded data to the Server, and reading JSON.

only using a common .jar file on both containing Entity POJOs.

the problem on GWT client side is a clean way of Converting JSON to
POJO back and forth.

I was wondering if the new AutoBean/RequestFactory/EntityProxy can
help in the situation I described ?


Can i still use "Editor" if I opt for JSON/REST solution above ?
What do you think of this approach ? do you think it may result in
performance problems ?

I am going to write both the client and servers in Java, and have
access to the code.
but my main concern is clean separation, complete isolation and loose
coupling.

I would like to know what are the down-sides to this, and if the new
2.1.1 features can help ?

these Architectural decisions are about tradeoff, I would like to know
what I am going to lose if I chose the approach I described above.

Thank You



karthik reddy

unread,
Jan 15, 2011, 2:03:11 PM1/15/11
to google-we...@googlegroups.com
very valid questions. A good number of gwt developers  at some stage will face similar questions. I would appreciate if someone could share their experiences and findings pertaining to the questions zixzigma has brought up.  

Y2i

unread,
Jan 15, 2011, 3:37:23 PM1/15/11
to google-we...@googlegroups.com


On Saturday, December 11, 2010 2:01:28 PM UTC-8, zixzigma wrote:
is it possible to use 2.1.1 RequestFactory/AutoBean to convert POJO to
JSON and viceversa
when interacting with a RESTful Web Service ?

the common practice with GWT client-server communication is
to have packages:
client, shared, server, configuring web.xml

however, in-order to be truly loosely coupled,
I am thinking of developing the Server side of my app,
as a REST WebService. completely separate from the client.
sending JSON encoded data to the Server, and reading JSON.

only using a common .jar file on both containing Entity POJOs.

the problem on GWT client side is a clean way of Converting JSON to
POJO back and forth.

I was wondering if the new AutoBean/RequestFactory/EntityProxy can
help in the situation I described ?

Clean conversion of JSON is achieved with com.google.gwt.jsonp.client.JsonpRequestBuilder
Request factory is not necessary.

These guidelines describe the basics of working with JSON and overlay types (JavaScript objects wrapped with Java facade)

com.google.gwt.jsonp.client.JsonpRequestBuilder simplifies things even more because there is no need to do any JSNI and eval().  
And it also allows for cross-site communication variant called JSON with padding, which is described in detail here:


Can i still use "Editor" if I opt for JSON/REST solution above ?
What do you think of this approach ? do you think it may result in
performance problems ?


Since overlay types look like POJOs, I think they should work with Editor framework, but I haven't tried that.
 

David Chandler

unread,
Jan 16, 2011, 1:20:00 AM1/16/11
to google-we...@googlegroups.com
Also, you may want to have a look at https://github.com/chirino/resty-gwt. It automates JSON<-->POJO mapping to REST-style services using a GWT generator. 

AutoBeans could certainly be used for JSON<-->POJO mapping, as RequestFactory uses both AutoBeans and JSON under the covers. However, the RequestFactory wire protocol is its own thing built on top of JSON, so it's not quite a direct POJO->JSON conversion in the sense you're thinking about. Better to pick RequestFactory or REST rather than try to marry them, I think, as REST and RPC of any kind are fundamentally different ways of thinking about remote services.

Editors are orthogonal to RequestFactory. Have a look at the SimpleBeanEditorDriver in 2.1 for use with your POJOs.

/dmc

 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
David Chandler
Developer Programs Engineer, Google Web Toolkit
w: http://code.google.com/
b: http://googlewebtoolkit.blogspot.com/
t: @googledevtools
Reply all
Reply to author
Forward
0 new messages