Class SerializablePortability
- java.lang.Object
-
- org.terracotta.offheapstore.storage.portability.SerializablePortability
-
- All Implemented Interfaces:
Portability<java.io.Serializable>
- Direct Known Subclasses:
PersistentSerializablePortability
public class SerializablePortability extends java.lang.Object implements Portability<java.io.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 theClassand the integer representation are stored in a single on-heap map.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classSerializablePortability.OIS(package private) classSerializablePortability.OOSprotected static classSerializablePortability.SerializableDataKey
-
Field Summary
Fields Modifier and Type Field Description private java.lang.ClassLoaderloaderprotected java.util.concurrent.ConcurrentMap<java.lang.Object,java.lang.Object>lookupprotected intnextStreamIndex
-
Constructor Summary
Constructors Constructor Description SerializablePortability()SerializablePortability(java.lang.ClassLoader loader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddedMapping(java.lang.Integer rep, java.io.ObjectStreamClass disconnected)java.io.Serializabledecode(java.nio.ByteBuffer buffer)Decodes aByteBufferto an object of typeT.protected static java.io.ObjectStreamClassdisconnect(java.io.ObjectStreamClass desc)java.nio.ByteBufferencode(java.io.Serializable object)Encodes an object of typeTas aByteBuffer.private static booleanequals(java.io.ObjectStreamClass osc1, java.io.ObjectStreamClass osc2)booleanequals(java.lang.Object value, java.nio.ByteBuffer readBuffer)Returns true if the encoded object once decoded would beObject.equals(Object)to the supplied object.private static booleanequals(SerializablePortability.SerializableDataKey k1, SerializablePortability.SerializableDataKey k2)java.io.ObjectInputStreamgetObjectInputStream(java.io.InputStream input)java.io.ObjectOutputStreamgetObjectOutputStream(java.io.OutputStream out)protected intgetOrAddMapping(java.io.ObjectStreamClass desc)private static byte[]getSerializedForm(java.io.ObjectStreamClass desc)
-
-
-
Method Detail
-
encode
public java.nio.ByteBuffer encode(java.io.Serializable object)
Description copied from interface:PortabilityEncodes an object of typeTas aByteBuffer.- Specified by:
encodein interfacePortability<java.io.Serializable>- Parameters:
object- object to be encoded- Returns:
- the encoded object
-
decode
public java.io.Serializable decode(java.nio.ByteBuffer buffer)
Description copied from interface:PortabilityDecodes aByteBufferto an object of typeT.- Specified by:
decodein interfacePortability<java.io.Serializable>- Parameters:
buffer- bytes to decode- Returns:
- the decoded object
-
getObjectOutputStream
public java.io.ObjectOutputStream getObjectOutputStream(java.io.OutputStream out) throws java.io.IOException- Throws:
java.io.IOException
-
getObjectInputStream
public java.io.ObjectInputStream getObjectInputStream(java.io.InputStream input) throws java.io.IOException- Throws:
java.io.IOException
-
equals
public boolean equals(java.lang.Object value, java.nio.ByteBuffer readBuffer)Description copied from interface:PortabilityReturns true if the encoded object once decoded would beObject.equals(Object)to the supplied object.- Specified by:
equalsin interfacePortability<java.io.Serializable>- Parameters:
value- object to compare toreadBuffer- buffer containing encoded object- Returns:
trueif the two parameters are "equal"
-
getOrAddMapping
protected int getOrAddMapping(java.io.ObjectStreamClass desc) throws java.io.IOException- Throws:
java.io.IOException
-
addedMapping
protected void addedMapping(java.lang.Integer rep, java.io.ObjectStreamClass disconnected)
-
equals
private static boolean equals(SerializablePortability.SerializableDataKey k1, SerializablePortability.SerializableDataKey k2)
-
equals
private static boolean equals(java.io.ObjectStreamClass osc1, java.io.ObjectStreamClass osc2)
-
disconnect
protected static java.io.ObjectStreamClass disconnect(java.io.ObjectStreamClass desc)
-
getSerializedForm
private static byte[] getSerializedForm(java.io.ObjectStreamClass desc) throws java.io.IOException- Throws:
java.io.IOException
-
-