Class AbstractPooledBufferByteArraySerializer

java.lang.Object
org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer
org.springframework.integration.ip.tcp.serializer.AbstractPooledBufferByteArraySerializer
All Implemented Interfaces:
Aware, ApplicationEventPublisherAware, Deserializer<byte[]>, Serializer<byte[]>
Direct Known Subclasses:
ByteArrayCrLfSerializer, ByteArrayRawSerializer, ByteArraySingleTerminatorSerializer, ByteArrayStxEtxSerializer

public abstract class AbstractPooledBufferByteArraySerializer
extends AbstractByteArraySerializer
Base class for deserializers that cannot determine the buffer size needed. Optionally pools buffers.
Since:
4.3
Author:
Gary Russell
  • Constructor Details

  • Method Details

    • setPoolSize

      public void setPoolSize​(int size)
      Set the pool size for deserialization buffers.
      Parameters:
      size - the size, -1 for unlimited.
      Since:
      4.3
    • setPoolWaitTimeout

      public void setPoolWaitTimeout​(long poolWaitTimeout)
      Set the pool wait timeout if a pool is configured, default unlimited.
      Parameters:
      poolWaitTimeout - the timeout.
    • deserialize

      public final byte[] deserialize​(InputStream inputStream) throws IOException
      Throws:
      IOException
    • doDeserialize

      protected abstract byte[] doDeserialize​(InputStream inputStream, byte[] buffer) throws IOException
      Parameters:
      inputStream - the input stream.
      buffer - the raw working buffer (maxMessageSize).
      Returns:
      the decoded bytes.
      Throws:
      IOException - an io exception.
      Since:
      4.3
    • copyToSizedArray

      protected byte[] copyToSizedArray​(byte[] buffer, int size)
      Copy size bytes to a new buffer exactly size bytes long. If a pool is not in use and the array is already the correct length, it is simply returned.
      Parameters:
      buffer - The buffer containing the data.
      size - The number of bytes to copy.
      Returns:
      The new buffer, or the buffer parameter if it is already the correct size and there is no pool.