org.terracotta.offheapstore.storage.portability
Class SerializablePortability

java.lang.Object
  extended by org.terracotta.offheapstore.storage.portability.SerializablePortability
All Implemented Interfaces:
Portability<Serializable>
Direct Known Subclasses:
PersistentSerializablePortability

public class SerializablePortability
extends Object
implements Portability<Serializable>

A trivially compressed Java serialization based portability.

Class descriptors in the resultant bytes are encoded as integers. Mappings between the integer representation and the ObjectStreamClass, and the Class and the integer representation are stored in a single on-heap map.

Author:
Chris Dennis

Nested Class Summary
protected static class SerializablePortability.SerializableDataKey
           
 
Field Summary
protected  ConcurrentMap<Object,Object> lookup
           
protected  int nextStreamIndex
           
 
Constructor Summary
SerializablePortability()
           
SerializablePortability(ClassLoader loader)
           
 
Method Summary
protected  void addedMapping(Integer rep, ObjectStreamClass disconnected)
           
 Serializable decode(ByteBuffer buffer)
          Decodes a ByteBuffer to an object of type T.
protected static ObjectStreamClass disconnect(ObjectStreamClass desc)
           
 ByteBuffer encode(Serializable object)
          Encodes an object of type T as a ByteBuffer.
 boolean equals(Object value, ByteBuffer readBuffer)
          Returns true if the encoded object once decoded would be Object.equals(Object) to the supplied object.
 ObjectInputStream getObjectInputStream(InputStream input)
           
 ObjectOutputStream getObjectOutputStream(OutputStream out)
           
protected  int getOrAddMapping(ObjectStreamClass desc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nextStreamIndex

protected int nextStreamIndex

lookup

protected final ConcurrentMap<Object,Object> lookup
Constructor Detail

SerializablePortability

public SerializablePortability()

SerializablePortability

public SerializablePortability(ClassLoader loader)
Method Detail

encode

public ByteBuffer encode(Serializable object)
Description copied from interface: Portability
Encodes an object of type T as a ByteBuffer.

Specified by:
encode in interface Portability<Serializable>
Parameters:
object - object to be encoded
Returns:
the encoded object

decode

public Serializable decode(ByteBuffer buffer)
Description copied from interface: Portability
Decodes a ByteBuffer to an object of type T.

Specified by:
decode in interface Portability<Serializable>
Parameters:
buffer - bytes to decode
Returns:
the decoded object

getObjectOutputStream

public ObjectOutputStream getObjectOutputStream(OutputStream out)
                                         throws IOException
Throws:
IOException

getObjectInputStream

public ObjectInputStream getObjectInputStream(InputStream input)
                                       throws IOException
Throws:
IOException

equals

public boolean equals(Object value,
                      ByteBuffer readBuffer)
Description copied from interface: Portability
Returns true if the encoded object once decoded would be Object.equals(Object) to the supplied object.

Specified by:
equals in interface Portability<Serializable>
Parameters:
value - object to compare to
readBuffer - buffer containing encoded object
Returns:
true if the two parameters are "equal"

getOrAddMapping

protected int getOrAddMapping(ObjectStreamClass desc)
                       throws IOException
Throws:
IOException

addedMapping

protected void addedMapping(Integer rep,
                            ObjectStreamClass disconnected)

disconnect

protected static ObjectStreamClass disconnect(ObjectStreamClass desc)


Copyright © 2016. All Rights Reserved.