Caching rpc payload in local storage

59 views
Skip to first unread message

timmys

unread,
Jun 16, 2011, 4:32:11 AM6/16/11
to Google Web Toolkit
Hi!

We've build an application that reads quite large objects graphs from
the server through the rpc mechanism.
This all works fine. But often these object graphs are identical
between browser sessions, so I was wondering if I could get the
underlying rpc payload string, store that using local storage, and
then reuse that at a later browser session. This would be a real nice
optimization. I just don't know how to achieve this, especially how to
hook in to gwt rpc to get the payload and how to deserialize that at a
later session. Anybody have any good ideas ??

Filipe Sousa

unread,
Jun 16, 2011, 4:39:33 AM6/16/11
to google-we...@googlegroups.com
On server side you  can override the method com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(String) that returns a string with the payload.

timmys

unread,
Jun 16, 2011, 8:21:10 AM6/16/11
to Google Web Toolkit
Yes, but what I really need is to do it on the client side.
Is there a similar method to override client side?
Or another way to hook into client side rpc stuff...?

lemaiol

unread,
Jun 17, 2011, 6:38:42 AM6/17/11
to Google Web Toolkit
Hi timmys,

Here an example with the payload embedded in the host page.

Hope it helps,
Berto

public static YourDomainObject getEmbeddedYourDomainObject() {
SerializationStreamFactory serializationStreamFactory =
GWT.create(IYoutRemoteService.class);
try {
String serializedYourDomainObject =
getEmbeddedObject("embeddedYourDomainObject");
if (null != serializedYourDomainObject) {
return (YourDomainObject)
serializationStreamFactory.createStreamReader(serializedYourDomainObject).readObject();
} else {
return null;
}
} catch (SerializationException e) {
throw new IllegalStateException("Error deserializing
embedded object.");
}
}

// Change this to your client-side storage option
private native static String getEmbeddedObject(String name) /*-{
return eval("$wnd." + name);
}-*/;
Reply all
Reply to author
Forward
0 new messages