Re: Replacing classes during custom serialization
Ah hah! The magic secret ingredient that will save me is the ability
to have different custom serializers on client and server, probably
via super-source. I hadn't thought of that.
Re-creating my Ref type hierarchy in super-source on the client is
annoying, but as you point out it's not an intractable problem since
all but the root can just be stub subclasses.
Thanks,
Jeff
On Tue, Apr 2, 2013 at 4:56 AM, Thomas Broyer <t.broyer@gmail.com> wrote:
>
>
> 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