Class AbstractKryoCodec

java.lang.Object
org.springframework.integration.codec.kryo.AbstractKryoCodec
All Implemented Interfaces:
Codec
Direct Known Subclasses:
PojoCodec

public abstract class AbstractKryoCodec extends Object implements Codec
Base class for Codecs using Kryo. Manages pooled Kryo instances.
Since:
4.2
Author:
David Turanski, Artem Bilan
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final com.esotericsoftware.kryo.util.Pool<com.esotericsoftware.kryo.Kryo>
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    configureKryoInstance(com.esotericsoftware.kryo.Kryo kryo)
    Subclasses implement this to configure the kryo instance.
    <T> T
    decode(byte[] bytes, Class<T> type)
    Decode an object of a given type.
    <T> T
    decode(InputStream inputStream, Class<T> type)
    Decode an object of a given type.
    protected abstract <T> T
    doDecode(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input, Class<T> type)
    Subclasses implement this method to decode with Kryo.
    protected abstract void
    doEncode(com.esotericsoftware.kryo.Kryo kryo, Object object, com.esotericsoftware.kryo.io.Output output)
    Subclasses implement this method to encode with Kryo.
    byte[]
    encode(Object object)
    Encode an object to a byte array.
    void
    encode(Object object, OutputStream outputStream)
    Encode (encode) an object to an OutputStream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • pool

      protected final com.esotericsoftware.kryo.util.Pool<com.esotericsoftware.kryo.Kryo> pool
  • Constructor Details

    • AbstractKryoCodec

      protected AbstractKryoCodec()
  • Method Details

    • encode

      public void encode(Object object, OutputStream outputStream)
      Description copied from interface: Codec
      Encode (encode) an object to an OutputStream.
      Specified by:
      encode in interface Codec
      Parameters:
      object - the object to encode
      outputStream - the OutputStream
    • decode

      public <T> T decode(byte[] bytes, Class<T> type) throws IOException
      Description copied from interface: Codec
      Decode an object of a given type.
      Specified by:
      decode in interface Codec
      Type Parameters:
      T - the object's type
      Parameters:
      bytes - the byte array containing the encoded object
      type - the object's class
      Returns:
      the object
      Throws:
      IOException - if the operation fails
    • decode

      public <T> T decode(InputStream inputStream, Class<T> type)
      Description copied from interface: Codec
      Decode an object of a given type.
      Specified by:
      decode in interface Codec
      Type Parameters:
      T - the object's type
      Parameters:
      inputStream - the input stream containing the encoded object
      type - the object's class
      Returns:
      the object
    • encode

      public byte[] encode(Object object) throws IOException
      Description copied from interface: Codec
      Encode an object to a byte array.
      Specified by:
      encode in interface Codec
      Parameters:
      object - the object to encode
      Returns:
      the bytes
      Throws:
      IOException - if the operation fails
    • doEncode

      protected abstract void doEncode(com.esotericsoftware.kryo.Kryo kryo, Object object, com.esotericsoftware.kryo.io.Output output)
      Subclasses implement this method to encode with Kryo.
      Parameters:
      kryo - the Kryo instance
      object - the object to encode
      output - the Kryo Output instance
    • doDecode

      protected abstract <T> T doDecode(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input, Class<T> type)
      Subclasses implement this method to decode with Kryo.
      Type Parameters:
      T - the type for decoded object
      Parameters:
      kryo - the Kryo instance
      input - the Kryo Input instance
      type - the class of the decoded object
      Returns:
      the decoded object
    • configureKryoInstance

      protected abstract void configureKryoInstance(com.esotericsoftware.kryo.Kryo kryo)
      Subclasses implement this to configure the kryo instance. This is invoked on each new Kryo instance when it is created.
      Parameters:
      kryo - the Kryo instance