Interface IElementSerializer
- All Known Implementing Classes:
- CompressingSerializer,- EncryptingSerializer,- StandardSerializer
public interface IElementSerializer
Defines the behavior for cache element serializers. This layer of abstraction allows us to plug
 in different serialization mechanisms, such as a compressing standard serializer.
- 
Method SummaryModifier and TypeMethodDescription<T> TdeSerialize(byte[] bytes, ClassLoader loader) Turns a byte array into an object.default <T> TdeSerializeFrom(InputStream is, ClassLoader loader) Convenience method to read serialized object from a stream.default <T> TdeSerializeFrom(AsynchronousByteChannel ic, int readTimeoutMs, ClassLoader loader) Convenience method to read serialized object from an asynchronous channel.default <T> TdeSerializeFrom(ReadableByteChannel ic, ClassLoader loader) Convenience method to read serialized object from a channel.<T> byte[]serialize(T obj) Turns an object into a byte array.default <T> intserializeTo(T obj, OutputStream os) Convenience method to write serialized object into a stream.default <T> intserializeTo(T obj, AsynchronousByteChannel oc, int writeTimeoutMs) Convenience method to write serialized object into an asynchronous channel.default <T> intserializeTo(T obj, WritableByteChannel oc) Convenience method to write serialized object into a channel.
- 
Method Details- 
serializeTurns an object into a byte array.- Type Parameters:
- T- the type of the object
- Parameters:
- obj- the object to serialize
- Returns:
- byte[] a byte array containing the serialized object
- Throws:
- IOException- if serialization fails
 
- 
deSerializeTurns a byte array into an object.- Parameters:
- bytes- data bytes
- loader- class loader to use
- Returns:
- Object
- Throws:
- IOException- if de-serialization fails
- ClassNotFoundException- thrown if we don't know the object.
 
- 
serializeToConvenience method to write serialized object into a stream. The stream data will be prepended with a four-byte length prefix.- Type Parameters:
- T- the type of the object
- Parameters:
- obj- the object to serialize
- os- the output stream
- Returns:
- the number of bytes written
- Throws:
- IOException- if serialization or writing fails
- Since:
- 3.1
 
- 
serializeToConvenience method to write serialized object into a channel. The stream data will be prepended with a four-byte length prefix.- Type Parameters:
- T- the type of the object
- Parameters:
- obj- the object to serialize
- oc- the output channel
- Returns:
- the number of bytes written
- Throws:
- IOException- if serialization or writing fails
- Since:
- 3.1
 
- 
serializeTodefault <T> int serializeTo(T obj, AsynchronousByteChannel oc, int writeTimeoutMs) throws IOException Convenience method to write serialized object into an asynchronous channel. The stream data will be prepended with a four-byte length prefix.- Type Parameters:
- T- the type of the object
- Parameters:
- obj- the object to serialize
- oc- the output channel
- writeTimeoutMs- the write timeout im milliseconds
- Returns:
- the number of bytes written
- Throws:
- IOException- if serialization or writing fails
- Since:
- 3.1
 
- 
deSerializeFromdefault <T> T deSerializeFrom(InputStream is, ClassLoader loader) throws IOException, ClassNotFoundException Convenience method to read serialized object from a stream. The method expects to find a four-byte length prefix in the stream data.- Type Parameters:
- T- the type of the object
- Parameters:
- is- the input stream
- loader- class loader to use
- Throws:
- IOException- if serialization or reading fails
- ClassNotFoundException- thrown if we don't know the object.
- Since:
- 3.1
 
- 
deSerializeFromdefault <T> T deSerializeFrom(ReadableByteChannel ic, ClassLoader loader) throws IOException, ClassNotFoundException Convenience method to read serialized object from a channel. The method expects to find a four-byte length prefix in the stream data.- Type Parameters:
- T- the type of the object
- Parameters:
- ic- the input channel
- loader- class loader to use
- Throws:
- IOException- if serialization or reading fails
- ClassNotFoundException- thrown if we don't know the object.
- Since:
- 3.1
 
- 
deSerializeFromdefault <T> T deSerializeFrom(AsynchronousByteChannel ic, int readTimeoutMs, ClassLoader loader) throws IOException, ClassNotFoundException Convenience method to read serialized object from an asynchronous channel. The method expects to find a four-byte length prefix in the stream data.- Type Parameters:
- T- the type of the object
- Parameters:
- ic- the input channel
- readTimeoutMs- the read timeout in milliseconds
- loader- class loader to use
- Throws:
- IOException- if serialization or reading fails
- ClassNotFoundException- thrown if we don't know the object.
- Since:
- 3.1
 
 
-