Package io.dapr.actors.runtime
Class ActorObjectSerializer
java.lang.Object
io.dapr.client.ObjectSerializer
io.dapr.actors.runtime.ActorObjectSerializer
public class ActorObjectSerializer extends ObjectSerializer
Serializes and deserializes internal objects.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ActorObjectSerializer() -
Method Summary
Modifier and Type Method Description <T> Tdeserialize(byte[] content, java.lang.Class<T> clazz)Deserializes the byte array into the original object.byte[]serialize(java.lang.Object state)Serializes a given state object into byte array.byte[]unwrapData(byte[] payload)Extracts the response data from a JSON Payload where data is in "data" attribute.byte[]wrapData(byte[] data)Wraps data in the "data" attribute in a JSON object.
-
Constructor Details
-
ActorObjectSerializer
public ActorObjectSerializer()
-
-
Method Details
-
serialize
public byte[] serialize(java.lang.Object state) throws java.io.IOExceptionSerializes a given state object into byte array.- Overrides:
serializein classObjectSerializer- Parameters:
state- State object to be serialized.- Returns:
- Array of bytes[] with the serialized content.
- Throws:
java.io.IOException- In case state cannot be serialized.
-
deserialize
public <T> T deserialize(byte[] content, java.lang.Class<T> clazz) throws java.io.IOExceptionDeserializes the byte array into the original object.- Overrides:
deserializein classObjectSerializer- Type Parameters:
T- Generic type of the object being deserialized.- Parameters:
content- Content to be parsed.clazz- Type of the object being deserialized.- Returns:
- Object of type T.
- Throws:
java.io.IOException- In case content cannot be deserialized.
-
unwrapData
public byte[] unwrapData(byte[] payload) throws java.io.IOExceptionExtracts the response data from a JSON Payload where data is in "data" attribute.- Parameters:
payload- JSON payload containing "data".- Returns:
- byte[] instance, null.
- Throws:
java.io.IOException- In case it cannot generate String.
-
wrapData
public byte[] wrapData(byte[] data) throws java.io.IOExceptionWraps data in the "data" attribute in a JSON object.- Parameters:
data- bytes to be wrapped into the "data" attribute in a JSON object.- Returns:
- String to be sent to Dapr's API.
- Throws:
java.io.IOException- If there's is any issue reading the data or wraping it
-