Tuesday, April 2, 2013

Re: Replacing classes during custom serialization



On Sunday, March 31, 2013 11:14:28 PM UTC+2, Jeff Schnitzer wrote:
As a second question, is there any document anywhere which describes
how custom serializers actually work?

I don't think so; at least not outside Google.
There's https://docs.google.com/document/d/1eG0YocsYYbNAtivkLtcaiEE5IOF5u4LUol8-LL0TIKU/edit about GWT-RPC serialization, but it's really light when it comes to custom serializers and simply defer to the DevGuide.
 
The tiny section in
DevGuideServerCommunication is not helpful. Some basic questions:

 * Are custom serializers server-side only? Or do they get executed on
the client-side too?

Custom serializers are used on both sides (isn't this clear from the doc?). If you need different implementations for the client and server, you can either have a Ref_ServerCustomFieldSerializer<Ref> or use super-sources (EnumMap and LinkedHashMap uses this, actually in addition to a ServerCustomFieldSerializer: the CustomFieldSerializer from "sources" is used in DevMode, the one from super-sources is annotated with @GwtScriptOnly and thus only used when compiled to JS, and the ServerCustomFieldSerializer is used on the server-side).

 * What's the relationship between the static methods and the instance
methods? I presume we have both for some sort of historical reason,
but can we get rid of the static methods? (last time I tried it didn't
work)

Actually, the static methods are used on client-side, while the instance methods are used on server-side (when they generally just defer to the static methods). Historically, custom serializers were only convention-based: must be named with the _CustomFieldSerializer suffix and have the serialize and deserialize static methods and optionally an instantiate static method. The CustomFieldSerializer interface was added in GWT 2.3, and the ServerCustomFieldSerializer added in GWT 2.5.0. The CustomFieldSerializer interface was added as an optimization, to avoid too much reflection at runtime on the server-side.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate