public interface ProxySerializer
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.
DefaultProxyStore| Modifier and Type | Method and Description |
|---|---|
<T extends BaseProxy> |
deserialize(java.lang.Class<T> proxyType,
java.lang.String key)
Recreate a proxy instance that was previously passed to
serialize(BaseProxy). |
<T extends EntityProxy> |
deserialize(EntityProxyId<T> id)
Recreate a
EntityProxy instance that was previously passed to
serialize(BaseProxy). |
java.lang.String |
serialize(BaseProxy proxy)
Store a proxy into the backing store.
|
<T extends BaseProxy> T deserialize(java.lang.Class<T> proxyType, java.lang.String key)
serialize(BaseProxy).T - the type of proxy object to createproxyType - the type of proxy object to createkey - a value previously returned from serialize(BaseProxy)null if the data
needed to deserialize the proxy is not present in the ProxyStore<T extends EntityProxy> T deserialize(EntityProxyId<T> id)
EntityProxy instance that was previously passed to
serialize(BaseProxy).T - the type of proxy object to createid - the EntityProxyId of the desired entitynull if the data
needed to deserialize the proxy is not present in the ProxyStorejava.lang.String serialize(BaseProxy proxy)
proxy - the proxy to storedeserialize(Class, String)