How to remove implementation types from GWT serialization policy?

The opposite of this question: How do I add a type to the GWT serialization policy whitelist?

GWT adds unwanted types to serialization policy and inflates my JS. How to crop your GWT whitelist manually? Or should I do at all?

For example, if I put the list of interfaces in the GWT RPC service class, GWT should generate Javascript that handles ArrayList, LinkedList, Stack, Vector, ... although my team knows that we will only ever return ArrayList. I could just make the method return an ArrayList type, but I like to rely on the interface, not the concrete implementation. In the end, perhaps one day we will turn it on and return it, for example. LinkedList In this case, I would like to force the GWT serialization policy to compile only for ArrayList and LinkedList. No stacks or vectors.

These implicit limitations have one huge flaw that I can think of: a new team member starts returning Vectors, which will be a run-time error. So, besides the question in the title, what is your design experience around this?

+5
source share
2 answers

There is a property that can perform a blacklist of this class. For example, in a blacklist of collections other than ArrayList, add these lines to your * .gwt.xml:

<extend-configuration-property name="rpc.blacklist" value="java.util.HashSet"/>
<extend-configuration-property name="rpc.blacklist" value="java.util.LinkedHashSet"/>
<extend-configuration-property name="rpc.blacklist" value="java.util.LinkedList"/>
<extend-configuration-property name="rpc.blacklist" value="java.util.Stack"/>
<extend-configuration-property name="rpc.blacklist" value="java.util.TreeMap"/>
<extend-configuration-property name="rpc.blacklist" value="java.util.TreeSet"/>
<extend-configuration-property name="rpc.blacklist" value="java.util.Vector"/>

This was necessary to reduce the size of JS when sending GWT inline objects com.google.gwt.user.client.ui.SuggestOracle$Responsefor wiring. Such objects contain java.util.Collection, but I knew that I would only ever send back an ArrayList.

- , , . , , GWT ( ?). "rpc.blacklist" SuggestOracle, .

+7

, , GWT , . , , , .

GWT RPC - , RPC, , List Map Set to your hearts content - GWT . ? . , GWT .

- RPC. RPC , RPC, , , , , , .

- GWT , , - . . , List - .

+6

All Articles