Revision: 10321
Author:   [email protected]
Date:     Sat Jun 11 17:16:56 2011
Log:      Edited wiki page RequestFactory_2_4 through web user interface.
http://code.google.com/p/google-web-toolkit/source/detail?r=10321

Modified:
 /wiki/RequestFactory_2_4.wiki

=======================================
--- /wiki/RequestFactory_2_4.wiki       Fri Jun 10 14:37:27 2011
+++ /wiki/RequestFactory_2_4.wiki       Sat Jun 11 17:16:56 2011
@@ -17,6 +17,7 @@
* (Issue 6253) All RequestFactory and AutoBean interfaces have moved to the `com.google.web.bindery' namespace * (Issue 6393) `RequestFactoryServlet.getThreadLocalServletContext()` provides access to the current HTTP request's `ServletContext` * (Issue 6469) Provide getters for `ServerFailure -> Request -> RequestContext -> RequestFactory -> RequestTransport`
+  * `RequestContext.append()` and `RequestBatcher` added

 == Polymorphism support ==

@@ -51,3 +52,34 @@
 == !ServiceLayer changes ==

Several of the `ServiceLayer.resolveX()` method signatures have changed in this release. These changes were made in order to allow the use of obfuscated type and operation tokens to reduce payload and generated JS size and to allow the use of overloaded method names in `RequestContext` subtypes. Users who have written their own `ServiceLayerDecorator` subclasses that override any of the `resolveX()` methods will need to modify their code to conform to the new API. In general, the expected behavior of the `resolveX()` methods is unchanged. Users who need to retain compatibility with 2.3 and 2.4 RequestFactory server code can leave methods with the old signatures in place, removing any `@Override` annotations.
+
+== Improved request batching ==
+
+Prior to GWT 2.4, it was only possible to chain `Request` instances that originated within a single `RequestContext`. GWT 2.4 adds a `RequestContext.append()` method, which allows cross-context chaining.
+{{{
+interface ContextA extends RequestContext {
+  Request<Boolean> requestA();
+}
+interface ContextB extends RequestContext {
+  Request<Integer> requestB();
+}
+interface MyRequestFactory extends RequestFactory {
+  ContextA ctxA();
+  ContextB ctxB();
+}
+class Caller {
+  MyRequestFactory factory;
+  void doSomething() {
+    ContextA ctxA = factory.ctxA();
+    ctxA.requestA().to(new Receiver<Boolean>(){});
+    ContextB ctxB = ctxA.append(factory.ctxB());
+    // ctxA is still completely usable after calling append()
+    ctxB.requestB().to(new Receiver<Boolean>(){});
+    ctxA.fire(); // ctxB.fire() would be equivalent
+  }
+}
+}}}
+
+Any `RequestContext` may have another newly-created `RequestContext` appended to it. Once two `RequestContext` instances are joined, they may be used independently of one another until `fire()` is called on any of the `RequestContext` instances.
+
+Building on top of the `append()` facility is the utility class `RequestBatcher` which makes it easy to combine all `Request`s made during one tick of the event loop into a single HTTP request. A `RequestBatcher` vends an instance of a `RequestContext` and automatically calls `fire()` on it before the JavaScript execution returns to the browser (via `Scheduler.scheduleFinally()`). The public `fire()` methods on the returned `RequestContext` and its `Request` objects will not trigger an HTTP request, although any `Receiver` provided will still be enqueued, allowing the `RequestContext` vended by a `RequestBatcher` to be used with existing code.

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to