org.terracotta.cache.serialization
Class DsoSerializationStrategy<T>

java.lang.Object
  extended by org.terracotta.cache.serialization.DsoSerializationStrategy<T>
Type Parameters:
T - value type
All Implemented Interfaces:
SerializationStrategy<T>, UnsafeSerializationStrategy<T>
Direct Known Subclasses:
DsoSerializationStrategy2

public class DsoSerializationStrategy<T>
extends Object
implements SerializationStrategy<T>, UnsafeSerializationStrategy<T>

A clusterable serialization strategy.


Nested Class Summary
protected static class DsoSerializationStrategy.OIS
           
protected static class DsoSerializationStrategy.OOS
           
 
Field Summary
protected static byte HIGH_BIT
           
protected  ObjectStreamClassSerializer oscSerializer
           
 
Constructor Summary
DsoSerializationStrategy()
          Construct a fully locking clusterable serialization strategy.
DsoSerializationStrategy(boolean internalLocking)
          Constructs an optionally locked clusterable serialization strategy.
 
Method Summary
protected static int decodeInt(InputStream is)
           
 T deserialize(byte[] data)
          Deserialize the serialized value returning a new representation.
 T deserialize(byte[] data, ClassLoader loader)
          Deserialize the serialized value using the specified loader, and returning a new representation.
protected static void encodeInt(OutputStream os, int value)
           
 String generateStringKeyFor(Object key)
          Convert the given key into a portable String form.
 byte[] serialize(T value)
          Serialize the given value into a detached, portable form.
 T unsafelyDeserialize(byte[] data)
           
 T unsafelyDeserialize(byte[] value, ClassLoader classLoader)
           
protected  void writeStringKey(Object key, ObjectOutputStream oos)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HIGH_BIT

protected static final byte HIGH_BIT
See Also:
Constant Field Values

oscSerializer

protected final ObjectStreamClassSerializer oscSerializer
Constructor Detail

DsoSerializationStrategy

public DsoSerializationStrategy()
Construct a fully locking clusterable serialization strategy.


DsoSerializationStrategy

public DsoSerializationStrategy(boolean internalLocking)
Constructs an optionally locked clusterable serialization strategy.

Non-locked instances can be used to provider tighter over lock scoping, and associated transaction scoping when serialization strategies are being used within operations that are intended to be atomic.

Parameters:
internalLocking - true if internal locking should be applied
Method Detail

deserialize

public T deserialize(byte[] data)
              throws IOException,
                     ClassNotFoundException
Description copied from interface: SerializationStrategy
Deserialize the serialized value returning a new representation.

Specified by:
deserialize in interface SerializationStrategy<T>
Parameters:
data - serialized form
Returns:
a new deserialized value
Throws:
IOException - if deserialization fails
ClassNotFoundException - if a required class is not found

deserialize

public T deserialize(byte[] data,
                     ClassLoader loader)
              throws IOException,
                     ClassNotFoundException
Description copied from interface: SerializationStrategy
Deserialize the serialized value using the specified loader, and returning a new representation.

Specified by:
deserialize in interface SerializationStrategy<T>
Parameters:
data - serialized form
loader - to use during deserialization
Returns:
a new deserialized value
Throws:
IOException - if deserialization fails
ClassNotFoundException - if a required class is not found

serialize

public byte[] serialize(T value)
                 throws IOException
Description copied from interface: SerializationStrategy
Serialize the given value into a detached, portable form.

Specified by:
serialize in interface SerializationStrategy<T>
Parameters:
value - value to serialize
Returns:
serialized form
Throws:
IOException - if serialization fails

generateStringKeyFor

public String generateStringKeyFor(Object key)
                            throws IOException
Description copied from interface: SerializationStrategy
Convert the given key into a portable String form.

Specified by:
generateStringKeyFor in interface SerializationStrategy<T>
Parameters:
key - key to serialize
Returns:
a portable String key
Throws:
IOException - if serialization fails

writeStringKey

protected void writeStringKey(Object key,
                              ObjectOutputStream oos)
                       throws IOException
Throws:
IOException

decodeInt

protected static final int decodeInt(InputStream is)
                              throws IOException
Throws:
IOException

encodeInt

protected static final void encodeInt(OutputStream os,
                                      int value)
                               throws IOException
Throws:
IOException

unsafelyDeserialize

public T unsafelyDeserialize(byte[] value,
                             ClassLoader classLoader)
                      throws IOException,
                             ClassNotFoundException
Specified by:
unsafelyDeserialize in interface UnsafeSerializationStrategy<T>
Throws:
IOException
ClassNotFoundException

unsafelyDeserialize

public T unsafelyDeserialize(byte[] data)
                      throws IOException,
                             ClassNotFoundException
Specified by:
unsafelyDeserialize in interface UnsafeSerializationStrategy<T>
Throws:
IOException
ClassNotFoundException


Copyright © 2015 Terracotta, Inc.. All Rights Reserved.