GWT-RPC does this by convention. The custom serializer must be in the same
package as the class it (de)serializes and is named <class
name>_CustomFieldSerializer, e.g. ImmutableSet_CustomFieldSerializer.
I wouldn't use an annotation because a guava collection could be used by a
large amount of classes so you only want to define the serializer once for
a given collection type. To do so you would need some kind of a
"configuration" class where you can put annotations once. Or use such a
configuration class the google-gin way:
void configure() {
serialize(ImmutableSet.class).with(ImmutableSetJsonSerializer.class).
}
If you don't want a configuration class then you could also define a
configuration property in your gwt module xml instead. That property could
then be filled by users of your library. The property values should point
to full qualified class names of custom serializers. google-gin also has an
example of this technique because you could define a configuration property
and then reference it on the Ginjector like:
@GinModules(value = MyModule.class, properties = {
"my.google.gin.extention.property1", "my.google.gin.extention.property2" }
public interface MyInjector extends Ginjector {}
<define-configuration-property
name="my.google.gin.extention.property1" is-multi-valued="true" /> (would
go in your library gwt xml)
<extend-configuration-property name="my.google.gin.extention.property1"
value="com.example.ExtentionModule" /> (thats what a library user would
need to define in their gwt xml)
-- J.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.