Interface ProxySerializer
-
public interface ProxySerializerSerializes graphs of EntityProxy objects. A ProxySerializer is associated with an instance of aProxyStorewhen it is created viaRequestFactory.getSerializer(ProxyStore).The
EntityProxy.stableId()of non-persisted (i.e. newlycreated)EntityProxyinstances 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:
DefaultProxyStore
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends EntityProxy>
Tdeserialize(EntityProxyId<T> id)Recreate aEntityProxyinstance that was previously passed toserialize(BaseProxy).<T extends BaseProxy>
Tdeserialize(java.lang.Class<T> proxyType, java.lang.String key)Recreate a proxy instance that was previously passed toserialize(BaseProxy).java.lang.Stringserialize(BaseProxy proxy)Store a proxy into the backing store.
-
-
-
Method Detail
-
deserialize
<T extends BaseProxy> T deserialize(java.lang.Class<T> proxyType, java.lang.String key)
Recreate a proxy instance that was previously passed toserialize(BaseProxy).- Type Parameters:
T- the type of proxy object to create- Parameters:
proxyType- the type of proxy object to createkey- a value previously returned fromserialize(BaseProxy)- Returns:
- a new, immutable instance of the proxy or
nullif the data needed to deserialize the proxy is not present in the ProxyStore
-
deserialize
<T extends EntityProxy> T deserialize(EntityProxyId<T> id)
Recreate aEntityProxyinstance that was previously passed toserialize(BaseProxy).- Type Parameters:
T- the type of proxy object to create- Parameters:
id- theEntityProxyIdof the desired entity- Returns:
- a new, immutable instance of the proxy or
nullif the data needed to deserialize the proxy is not present in the ProxyStore
-
serialize
java.lang.String serialize(BaseProxy proxy)
Store a proxy into the backing store.- Parameters:
proxy- the proxy to store- Returns:
- a key value that can be passed to
deserialize(Class, String)
-
-