eneter.messaging.endpoints.rpc
Class RpcCustomSerializer

java.lang.Object
  extended by eneter.messaging.endpoints.rpc.RpcCustomSerializer
All Implemented Interfaces:
ISerializer

public class RpcCustomSerializer
extends java.lang.Object
implements ISerializer

Serializer optimized for RPC. Peroformance of this serializer is optimized for RPC. To increase the performance it serializes RpcMessage (which is internaly used for RPC interaction) into a special byte sequence. It uses underlying serializer to serialize method inrput paramters.


Constructor Summary
RpcCustomSerializer(ISerializer serializer)
          Constructs the serializer.
 
Method Summary
<T> T
deserialize(java.lang.Object serializedData, java.lang.Class<T> clazz)
          Deserializes data.
<T> java.lang.Object
serialize(T dataToSerialize, java.lang.Class<T> clazz)
          Serializes data.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RpcCustomSerializer

public RpcCustomSerializer(ISerializer serializer)
Constructs the serializer.

Parameters:
serializer - Underlying serializer used to serialize/deserialize method's input parameters.
Method Detail

serialize

public <T> java.lang.Object serialize(T dataToSerialize,
                                      java.lang.Class<T> clazz)
                           throws java.lang.Exception
Serializes data. If the serialized type is RpcMessage then it serializes it into the special sequence otherwise it uses the underlying serializer to serialize it.

Specified by:
serialize in interface ISerializer
Parameters:
dataToSerialize - Data to be serialized.
clazz - represents the serialized type.
Returns:
Object representing the serialized data. Based on the serializer implementation it can be byte[] or String.
Throws:
java.lang.Exception - If the serialization fails.

deserialize

public <T> T deserialize(java.lang.Object serializedData,
                         java.lang.Class<T> clazz)
              throws java.lang.Exception
Description copied from interface: ISerializer
Deserializes data.

Specified by:
deserialize in interface ISerializer
Parameters:
serializedData - Data to be deserialized.
Returns:
Deserialized object.
Throws:
java.lang.Exception - If the deserialization fails.