SimpleRequestProcessor call find<Domain> twice

9 views
Skip to first unread message

Andy

unread,
Sep 3, 2011, 10:56:42 AM9/3/11
to Google Web Toolkit
Hi,

I have an example class

public class Employee {

public static Employee findEmployee(ObjectId id) {
.................
System.out.println("find");
return employee;
}
......
}

When triggering the findEmloyee from the client side via
RequestContext, the line 'System.out.println("find");' was called
twice, I check that it is called from the class
SimpleRequestProcessor, from the two method

method createReturnOperations, triggered by the line
} else if (!service.isLive(domainObject)) {
in the method

method processInvocationMessages, triggered by the line
domainReturnValue = service.invoke(domainMethod,
args.toArray());

Both this method is triggered from the method
void process(RequestMessage req, ResponseMessage resp)

The questions is why createReturnOpration need to find the employee
again which i think is unnecessary.

It is just loaded from the database and then it will hit the database
again for the same query? Am I doing something wrong here ?

Kind Regards
Andy

Thomas Broyer

unread,
Sep 3, 2011, 11:14:23 AM9/3/11
to google-we...@googlegroups.com
As the code says: it tries to determine whether the object still "isLive" (in order to tell the client that it has been deleted, or possibly updated).

If you have a better algorithm to determine "liveness", use a Locator and override its isLive method.
Reply all
Reply to author
Forward
0 new messages