Javadoc for RequestContext#fire()
says only:
Send the accumulated changes and method invocations associated with the RequestContext.
GWT Moving Parts wiki entry under Flow section says only:
- All accumulated operations will be applied to the domain objects by traversing properties of the proxies.
- All method invocations in the payload are executed.
But will these methods be executed on the server side in the same order they were "executed" (accumulated) on ReqestContext
instance on client side?
For my situation, if I execute on client side:
context.persist().using(proxy)
context.find(proxy.stableId().to(updatingReceiver))
context.fire()
Then may I be sure that on server side find()
will be invoked after persist()
so my updatingReceiver
will get proxy of updated (persist()
'ed) entity as an argument?
EDIT:
Going further, may I be sure that back on client after response Reciever
s will be invoked in exactly the same order in which their corresponding methods were accumulated?
Finally, is there a way to add some action that will be invoked at the end of response handling, after all Receiver
s' actions?
I thought something like this may work:
requestContext.fire(new Receiver<Void>() {
@Override
public void onSuccess(Void response) {
//Things to do after all receivers
});
And it really seems to work as I expected but because all that Javadoc is telling me about RequestContext.fire(Receiver)
method is:
For receiving errors or validation failures only.
I'm not 100% sure whether my assumption is correct.
Yes, order of method invocations is preserved, both on the server-side and then back on the client side when calling Reciever
s.
The queue is a simple ArrayList
in which invocation objects are appended. On the server-side, they're processed in the order they're received.
The Request-Context
-level Receiver
is always called after the ones for invocations. Its onSuccess
is always called, whatever the result of the invocations (even if they all fail), to signal that the batch of invocations was processed successfully. Its onFailure
is only called in case of a general failure, i.e. a network error, or an error when (de)serializing requests/responses on the server-side.
See http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/web/bindery/requestfactory/shared/impl/AbstractRequestContext.java?r=10835#345