public class

SerializableTypeOracleBuilder

extends Object
java.lang.Object
   ↳ com.google.gwt.user.rebind.rpc.SerializableTypeOracleBuilder

Class Overview

Builds a SerializableTypeOracle for a given set of root types.

There are two goals for this builder. First, discover the set of serializable types that can be serialized if you serialize one of the root types. Second, to make sure that all root types can actually be serialized by GWT.

To find the serializable types, it includes the root types, and then it iteratively traverses the type hierarchy and the fields of any type already deemed serializable. To improve the accuracy of the traversal there is a computations of the exposure of type parameters. When the traversal reaches a parameterized type, these exposure values are used to determine how to treat the arguments.

A type qualifies for serialization if it or one of its subtypes is automatically or manually serializable. Automatic serialization is selected if the type is assignable to IsSerializable or Serializable or if the type is a primitive type such as int, boolean, etc. Manual serialization is selected if there exists another type with the same fully qualified name concatenated with "_CustomFieldSerializer". If a type qualifies for both manual and automatic serialization, manual serialization is preferred.

Some types may be marked as "enhanced," either automatically by the presence of a JDO @PersistenceCapable or JPA @Entity tag on the class definition, or manually by extending the 'rpc.enhancedClasses' configuration property in the GWT module XML file. For example, to manually mark the class com.google.myapp.MyPersistentClass as enhanced, use:

 
 

Enhanced classes are checked for the presence of additional serializable fields on the server that were not defined in client code as seen by the GWT compiler. If it is possible for an instance of such a class to be transmitted bidrectionally between server and client, a special RPC rule is used. The server-only fields are serialized using standard Java serialization and sent between the client and server as a blob of opaque base-64 encoded binary data. When an instance is sent from client to server, the server instance is populated by invoking setter methods where possible rather than by setting fields directly. This allows APIs such as JDO the opportunity to update the object state properly to take into account changes that may have occurred to the object's state while resident on the client.

Summary

Public Constructors
SerializableTypeOracleBuilder(TreeLogger logger, PropertyOracle propertyOracle, TypeOracle typeOracle)
Constructs a builder.
Public Methods
void addRootType(TreeLogger logger, JType type)
SerializableTypeOracle build(TreeLogger logger)
Builds a SerializableTypeOracle for a given set of root types.
static JClassType findCustomFieldSerializer(TypeOracle typeOracle, JType type)
Finds the custom field serializer for a given type.
void setLogOutputWriter(PrintWriter logOutputWriter)
Set the PrintWriter which will receive a detailed log of the types which were examined in order to determine serializability.
void setTypeFilter(TypeFilter typeFilter)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public SerializableTypeOracleBuilder (TreeLogger logger, PropertyOracle propertyOracle, TypeOracle typeOracle)

Constructs a builder.

Throws
UnableToCompleteException if we fail to find one of our special types

Public Methods

public void addRootType (TreeLogger logger, JType type)

public SerializableTypeOracle build (TreeLogger logger)

Builds a SerializableTypeOracle for a given set of root types.

Returns
Throws
UnableToCompleteException if there was not at least one instantiable type assignable to each of the specified root types

public static JClassType findCustomFieldSerializer (TypeOracle typeOracle, JType type)

Finds the custom field serializer for a given type.

Returns
  • the custom field serializer for a type or null if there is not one

public void setLogOutputWriter (PrintWriter logOutputWriter)

Set the PrintWriter which will receive a detailed log of the types which were examined in order to determine serializability.

public void setTypeFilter (TypeFilter typeFilter)