Jetty has moved!
Jetty is a project at the Eclipse Foundation.
Homepage:http://www.eclipse.org/jetty
Downloads: http://download.eclipse.org/jetty/
Documentation:http://www.eclipse.org/jetty/documentation/current/
About:http://www.eclipse.org/jetty/about.php
Jetty Powered:http://www.eclipse.org/jetty/powered/
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

Google Web Toolkit

For usage and examples, see GWT RPC Examples
Setup

1. Add the jetty-gwt.jar to your lib/dependencies (if using jetty7, its available in 7.0.0pre3 and up)

2. Edit your class to extend AsyncRemoteServiceServlet

3. Clear your gwt-cache(only the first time)

4. Recompile your gwt-project

Explanation

The Google Web Toolkit allows Ajax applications to be developed in java code using the traditional UI widget paradigm. The toolkit includes support for RPC, but not for comet style Ajax push.

Unfortunately GWT has not made it easy to use continuations within their RPC mechanism. Firstly they catch Throwable, so the Jetty RetryException is caught. Secondly they have made most of the methods on the GWT servlet final, so you cannot fix this by extension.

GWT 1.5.x and below

Luckily GWT is open sourced under the apache 2.0 license, so it was possible to do a cut/paste/edit job to fix this. The OpenRemoteServiceServlet recently added to Jetty is a version of GWTs RemoteServiceServlet without the final methods and a protected method for extending exception handling.

Once the GWT remote service servlet has been opened up, it is trivial to extend it to support Continuations, which has been done in AsyncRemoteServiceServlet.

Because GWT RPC uses POSTS, the body of the request is consumed when the request is first handled and is not available when the request is retried. To handle this, the parsed contents of the POST are stored as a request attribute so they are available to retried requests without reparsing:

GWT 1.6.x+

The OpenRemoteServiceServletis no longer needed.  The RemoteServiceServlet has been updated and the limitations mentioned above are no more.  You can either patch a copy of AsyncRemoteServiceServletin your project, until a new jetty-gwt.jar release, or override the readContent(HttpServletRequest request) and doUnexpectedFailure(Throwable caught) in your subclass.  Here is the overide for that replaced readPayloadAsUtf8 as mentioned above.

The exception handling is also extended to allow the continuation RetryException to propagate to the container. This has been done without any hard dependencies on Jetty code. With these extensions, the AsyncRemoteServiceServlet allows any GWT RCP method to use continuations to suspend/resume processing. All you need to do is to have your servlet implementation extend the org.mortbay.gwt.AsyncRemoteServiceServlet:

For example below is a Table class from http://www.gpokr.com where a continuation is used by the service implementation to wait for an event to be available for a player:

GWT 1.5.x and below

You will need to build and then include the jetty-gwt-<version>.jar in your webapp. The source is included with every download of jetty. To build:

Note that OpenRemoteServiceServlet was created due to the fact that it was not possible to subclass google's RemoteServiceServlet (unless we use reflections)
Details below:

GWT 1.6.x+

Just extend RemoteServiceServlet and override readContent(HttpServletRequest request), shown above, and doUnexpectedFailure(Throwable caught).

  • No labels
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery