Class JavaSerializationCopier
- java.lang.Object
-
- com.github.benmanes.caffeine.jcache.copy.AbstractCopier<byte[]>
-
- com.github.benmanes.caffeine.jcache.copy.JavaSerializationCopier
-
- All Implemented Interfaces:
Copier
public class JavaSerializationCopier extends AbstractCopier<byte[]>
A strategy that uses Java serialization if a fast path approach is not applicable.Beware that native serialization is slow and is provided for completeness. In practice, it is recommended that a higher performance alternative is used, which is provided by numerous external libraries.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classJavaSerializationCopier.ClassLoaderAwareObjectInputStreamAn ObjectInputStream that instantiates using the supplied classloader.
-
Constructor Summary
Constructors Constructor Description JavaSerializationCopier()JavaSerializationCopier(Set<Class<?>> immutableClasses, Map<Class<?>,Function<Object,Object>> deepCopyStrategies)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Objectdeserialize(byte[] data, ClassLoader classLoader)Deserializes the data using the provided classloader.protected byte[]serialize(Object object)Serializes the object.-
Methods inherited from class com.github.benmanes.caffeine.jcache.copy.AbstractCopier
canDeeplyCopy, copy, isImmutable, javaDeepCopyStrategies, javaImmutableClasses, roundtrip
-
-
-
-
Method Detail
-
serialize
protected byte[] serialize(Object object)
Description copied from class:AbstractCopierSerializes the object.- Specified by:
serializein classAbstractCopier<byte[]>- Parameters:
object- the object to serialize- Returns:
- the serialized bytes
-
deserialize
protected Object deserialize(byte[] data, ClassLoader classLoader)
Description copied from class:AbstractCopierDeserializes the data using the provided classloader.- Specified by:
deserializein classAbstractCopier<byte[]>- Parameters:
data- the serialized bytesclassLoader- the classloader to create the instance with- Returns:
- the deserialized object
-
-