public class JavaHandler extends Object implements DataHandler
RedisClassDescriptorStorageFactory
instead of the default PerConnectionRedisClassDescriptorStorageFactory
.
Normal and optimized serialization are prefixed by different headers
so that they can be Serialized by a JavaHandler with or without the optimzeObjectStorage set.Modifier and Type | Field and Description |
---|---|
protected ClassDescriptorStorageFactory |
classDescriptorStorageFactory
Factory to get an appropriate
ClassDescriptorStorage when optimizeObjectStorage is enabled. |
static int |
ESCAPE_MARKER |
static int |
GZIP_HEADER |
static int |
OBJECT_STREAM_HEADER |
protected boolean |
optimizeObjectStorage
Indicates if Object Serialization is optimized by storing the Class Descriptors in a common location.
|
protected boolean |
serializeNumbers
Indicates whether to serialize numbers.
|
Constructor and Description |
---|
JavaHandler()
Creates a JavaHandler without optimeObjectStorage set to false.
|
JavaHandler(ClassDescriptorStorageFactory pclassDescriptorStorageFactory,
boolean poptimizeObjectStorage)
Creates a JavaHandler.
|
Modifier and Type | Method and Description |
---|---|
Object |
deserialize(Object metaData,
byte[] b,
int offset,
int len,
ServerInfo serverInfo)
de-serialize value
|
String |
getCharEncoding()
Gets the character encoding used for Serializing Strings.
|
int |
getObjectCompressionThreshold()
Gets the Object Compression Threshold.
|
int |
getStringCompressionThreshold()
Gets the String Compression Threshold, -2 indicates that the AsyncRedisConnection's
compressionThreshold is to be used.
|
boolean |
isOptimizeObjectStorage()
Checks if ptimizeObjectStorage (OPTI_JAVA_HANDLER) is enabled
|
boolean |
isSerializeNumbers()
Checks if
Number s are to be Serialized as Java Objects. |
void |
serialize(Object data,
Object metaData,
CompressibleByteArrayOutputStream op,
ServerInfo serverInfo)
Serialze value
|
void |
setCharEncoding(String pcharEncoding)
Sets the character encoding to use for Serializing Strings.
|
void |
setObjectCompressionThreshold(int pobjectCompressionThreshold)
Sets the Object Compression Threshold.
|
void |
setSerializeNumbers(boolean pserializeNumbers)
Sets Serialization option for java Numbers.
|
void |
setStringCompressionThreshold(int pstringCompressionThreshold)
Sets the String Compression Threshold.
|
public static final int ESCAPE_MARKER
public static final int GZIP_HEADER
public static final int OBJECT_STREAM_HEADER
protected ClassDescriptorStorageFactory classDescriptorStorageFactory
ClassDescriptorStorage
when optimizeObjectStorage is enabled.protected boolean optimizeObjectStorage
protected boolean serializeNumbers
public JavaHandler()
public JavaHandler(ClassDescriptorStorageFactory pclassDescriptorStorageFactory, boolean poptimizeObjectStorage)
pclassDescriptorStorageFactory
- Factory to Store ClassDescriptors. This must be non null if optimizeObjectStorage parameter is passed as true.poptimizeObjectStorage
- true for Optimizing Object Storage (OPTI_JAVA_HANDLER), false for regular java serializationpublic void serialize(Object data, Object metaData, CompressibleByteArrayOutputStream op, ServerInfo serverInfo) throws IOException
DataHandler
serialize
in interface DataHandler
data
- Data to serializemetaData
- Additional Info to serialize if required by the handler like the Object Class for example.
Pass null if the Data Handler does not require addtional info.op
- An output stream which can automatically compress the data in a session if it crosses a configured.
Compression ThresholdserverInfo
- Redis ServerInfo containing the Redis Server detailsIOException
- If there is an error during serializationpublic Object deserialize(Object metaData, byte[] b, int offset, int len, ServerInfo serverInfo) throws IOException
DataHandler
deserialize
in interface DataHandler
metaData
- Additional Info to de-serialize if required by the handlerb
- Byte Array containing the data from the Redis Serveroffset
- Starting offset of the datalen
- Length of the data in bytesserverInfo
- Redis ServerInfo containing the Redis Server detailsIOException
- If there is an error during de-serializationpublic String getCharEncoding()
public void setCharEncoding(String pcharEncoding)
pcharEncoding
- Character Encodingpublic int getStringCompressionThreshold()
public void setStringCompressionThreshold(int pstringCompressionThreshold)
pstringCompressionThreshold
- String CompressionThresholdpublic int getObjectCompressionThreshold()
public void setObjectCompressionThreshold(int pobjectCompressionThreshold)
pobjectCompressionThreshold
- Object CompressionThresholdpublic boolean isOptimizeObjectStorage()
public boolean isSerializeNumbers()
Number
s are to be Serialized as Java Objects. The default is false.public void setSerializeNumbers(boolean pserializeNumbers)
pserializeNumbers
- true to serialize Numbers as Obects, false to serialize them as StringCopyright © 2013- Suresh Mahalingam. All Rights Reserved.