Class CompactJavaSerializer<T>

java.lang.Object
org.ehcache.impl.serialization.CompactJavaSerializer<T>
All Implemented Interfaces:
org.ehcache.spi.serialization.Serializer<T>, org.ehcache.spi.serialization.StatefulSerializer<T>

public class CompactJavaSerializer<T> extends Object implements org.ehcache.spi.serialization.StatefulSerializer<T>
A trivially compressed Java serialization based serializer.

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.

  • Constructor Details

    • CompactJavaSerializer

      public CompactJavaSerializer(ClassLoader loader)
      Constructor to enable this serializer as a transient one.
      Parameters:
      loader - the classloader to use
      See Also:
      • Serializer
  • Method Details

    • asTypedSerializer

      public static <T> Class<? extends org.ehcache.spi.serialization.Serializer<T>> asTypedSerializer()
    • init

      public void init(org.ehcache.spi.persistence.StateRepository stateRepository)
      Specified by:
      init in interface org.ehcache.spi.serialization.StatefulSerializer<T>
    • serialize

      public ByteBuffer serialize(T object) throws org.ehcache.spi.serialization.SerializerException
      Specified by:
      serialize in interface org.ehcache.spi.serialization.Serializer<T>
      Throws:
      org.ehcache.spi.serialization.SerializerException
    • read

      public T read(ByteBuffer binary) throws ClassNotFoundException, org.ehcache.spi.serialization.SerializerException
      Specified by:
      read in interface org.ehcache.spi.serialization.Serializer<T>
      Throws:
      ClassNotFoundException
      org.ehcache.spi.serialization.SerializerException
    • equals

      public boolean equals(T object, ByteBuffer binary) throws ClassNotFoundException, org.ehcache.spi.serialization.SerializerException
      Specified by:
      equals in interface org.ehcache.spi.serialization.Serializer<T>
      Throws:
      ClassNotFoundException
      org.ehcache.spi.serialization.SerializerException