Interface ProxySerializer


public interface ProxySerializer
Serializes graphs of EntityProxy objects. A ProxySerializer is associated with an instance of a ProxyStore when it is created via RequestFactory.getSerializer(ProxyStore).

The EntityProxy.stableId() of non-persisted (i.e. newly created) EntityProxy instances are not stable.

To create a self-contained message that encapsulates a proxy:

 RequestFactory myFactory = ...;
 MyFooProxy someProxy = ...;
 
 DefaultProxyStore store = new DefaultProxyStore();
 ProxySerializer ser = myFactory.getSerializer(store);
 // More than one proxy could be serialized
 String key = ser.serialize(someProxy);
 // Create the flattened representation
 String payload = store.encode();
 
To recreate the object:
 ProxyStore store = new DefaultProxyStore(payload);
 ProxySerializer ser = myFactory.getSerializer(store);
 MyFooProxy someProxy = ser.deserialize(MyFooProxy.class, key);
 
If two objects refer to different EntityProxy instances that have the same stableId(), the last mutable proxy encountered will be preferred, otherwise the first immutable proxy will be used.
See Also: