GWT and Restlet is a *very* different paradigm from GWT-RPC.  There is no
creation of RPC interfaces, no Async or Service constructs.  That is, as
Justin said, an abstraction that largely pretends the Web isn't there,
instead of leveraging its capabilities.  This is why GWT-RPC is not a
feature of GWT we use very much at our shop ... it creates a silo between
client and server that I'd rather never introduce, and the abstraction
doesn't add any value for me, given that I don't like the RPC pattern
anyway.

The main value of GWT for me is the ability to reuse a lot of server-side
Java code directly on the browser, without rewriting and maintaining it in
Javascript or requiring client-side plugin support.  I guess I am often
perfectly happy to abstract away the *browser* and *JavaScript* -- call it
lingering post-traumatic shock from the browser wars -- but I would prefer
to not abstract away the *web,* whose architecture I find quite wonderful.
And there is a lot of time and cost savings in the ability to have objects
that port unmodified from browser to server.  Major server scalability
benefits come from moving a lot of work to the client, and with GWT this is
quite easy to do.

GWT's not a fit for all situations, and you can find plenty of instances on
the Web of me or people from my shop telling someone NOT to employ GWT for a
particular use case.  It's especially inefficient for making little widgets
that could be coded up in a few lines of JavaScript, or for mixing "page
oriented" and "application oriented" development styles.  It is quite good
for full-screen, long-lived, large, rich Internet applications.  We like it
a lot in these cases.

To use GWT and Restlet together, you write a standard Restlet server
application (that can be consumed by any RESTful client, not just GWT) ...
and then you can use the Restlet GWT client API (or any other HTTP-centric
or RESTful API) to fetch things from the server.

The test tree of the GWT source does have a complete working example of both
sides talking ... have a look here:

http://restlet.tigris.org/source/browse/restlet/trunk/modules/org.restlet.test/src/org/restlet/test/gwt/

particularly see client/TestClient.java, which contains this pattern of how
to make a request from the client side:

        button.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                new Client(Protocol.HTTP).put(
                        "http://localhost:8888/demo/hello.txt";, "entity",
                        new Callback() {
                            @Override
                            public void onEvent(Request request,
                                    Response response) {
                                try {
                                    label.setText(response.getEntity()
                                            .getText());
                                } catch (final Exception ioException) {
                                    GWT.log("Restlet I/O failed", ioException);
                                }
                            }

                        });
            }
        });

There are two differences between this and regular Restlet programming:

1) The callback pattern -- needed to deal with the fact that JavaScript is
asynchronous, but a sketch of available patterns in future Restlet Java
versions -- differs from normal Java Restlet 1.1, in which a put, get,
handle, etc. is synchronous and returns a Response directly.

2) The GWT client imports org.restlet.gwt... instead of org.restlet...
Eventually we would like to make this go away, but can't until core Restlet
supports asynchronous patterns.

I still hope to contribute some simple examples beyond the short test above
as soon as possible.

- Rob

On Tue, Sep 9, 2008 at 4:10 PM, Justin Makeig <[EMAIL PROTECTED]>wrote:

> I don't mean to throw a wet blanket on the GWT discussion, but my
> (limited) impression of GWT was that it was trying to abstract away
> the web, rather than embrace it. Rather than dealing with loosely
> coupled services, resources, and representations, it wraps everything
> into a nice tidy Java API that would be familiar to Swing and RPC
> service developers. I certainly think there's a good place for
> frameworks like these (just look at the popularity of GWT), but trying
> to adapt it to a REST world sounds like you're barking up the wrong
> tree.
> I'd love to hear other points of view, though.
>
> Justin
>
> On Tue, Sep 9, 2008 at 12:29 PM, Mark Petrovic <[EMAIL PROTECTED]>
> wrote:
> > Does someone have a single snippet of code that shows how the Restlet-GWT
> > API would work with the GWT tutorial w/RPC in StockWatcher?  Pseudo code
> > would be fine.
> >
> http://code.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=google-web-toolkit-doc-1-5&t=GettingStartedRPC
> > That is, what would the -Async and Service interface look like, and what
> > part, if any, do annotations like
> @RemoteServiceRelativePath("stockPrices")
> > play when using Restlet-GWT?
> > Thanks.
> >
> > On Sep 8, 2008, at 6:14 AM, Rob Heittman wrote:
> >
> > Restlet's GWT (Server) Extension, being just a wrapper around
> ServerServlet
> > that can also pass calls to the GWT Hosted Mode adapter, is one small
> class
> > file that has been in 1.1 milestone builds for almost a year now.  My
> > company uses it in a number of large production and in-development
> > applications.  These do not use Restlet-GWT API yet (though we are
> starting
> > to port), but use GWT's built in facilities or JSNI to talk to a
> > Restlet-powered server.
> >
> > The Restlet-GWT API (the port of the core Restlet API to work under GWT
> 1.5)
> > was a much larger undertaking afflicted by a lot of design complexity,
> the
> > moving target of GWT 1.5, and requiring the wisdom and time of Jerome,
> the
> > Restlet project founder, to accomplish.
> > - Rob
> >
> > On Sun, Sep 7, 2008 at 11:18 PM, Mark Petrovic <[EMAIL PROTECTED]>
> wrote:
> >>
> >> Thank you for the kind and speedy response, Rob.
> >> I intend to spend the week, and then some, on this subject, and would be
> >> happy to receive any guidance or code you can muster.  In return, I can
> post
> >> my newcomer questions and results.
> >> I'm curious:  how is it that the hosted mode Restlet GWT Extension is
> >> heavily exercised, but the Restlet-GWT API is not?  And what is the
> >> difference again?
> >> Mark
> >> On Sep 7, 2008, at 8:10 PM, Rob Heittman wrote:
> >>
> >> Hi Mark, I've been working on a longish example ("Chesstlet") that pulls
> >> together a number of Restlet and GWT techniques, but this won't be ready
> >> until November, due to some commitments I have in early October that
> >> complicate my availability.  In the meantime, maybe the best thing to do
> >> would be to pull together a small illustration based on the test case
> >> already in the Restlet source -- just beefing it up to do some useful
> things
> >> beyond hello, world.  I will try to get that together (or ask someone
> else
> >> at the office to do so) in the next day or two.
> >>
> >> The Restlet-GWT API is still largely unexercised (as opposed to the
> >> Restlet GWT Extension, which is just the hosted mode wrapper for
> >> ServerServlet, which is very heavily exercised) so we are discovering
> all
> >> sorts of new issues as we try it out.  So you should probably be working
> >> from a Restlet snapshot to pick up all the latest commits.  I think the
> >> latest important thing was an infinite recursion that Thierry removed.
>  Now
> >> that GWT 1.5 is final and we don't have to chase a moving target any
> more,
> >> it will be easier to stabilize this.
> >> - Rob
> >> On Sun, Sep 7, 2008 at 10:48 PM, Mark Petrovic <[EMAIL PROTECTED]>
> >> wrote:
> >>>
> >>> Good day.  I'm new here, but not new to Java and its supporting
> >>> technologies.
> >>>
> >>> I'm embarking on teaching myself GWT using Restlets, neither of which I
> >>> have programmed before, although I have read the documentation for
> each.  I
> >>> know that at the time the Restlet-GWT code was released, a whopping 6
> weeks
> >>> ago :-), there were no examples illustrating its use.  Perhaps there
> are
> >>> snippets of examples the community can share now, some weeks after the
> >>> release.  If you have such examples, I would be quite grateful to study
> >>> them, as would be, I'm sure, other newcomers to these subjects.  I am
> >>> particularly interested in running the server side using the Restlet
> NET
> >>> connector.
> >>>
> >>> All the pieces are in front of me; at this point a few well placed
> >>> examples would help bring it all together.
> >>>
> >>> Thank you.
> >>
> >>
> >
> >
> >
>

Reply via email to