Class AbstractPooledBufferByteArraySerializer
java.lang.Object
org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer
org.springframework.integration.ip.tcp.serializer.AbstractPooledBufferByteArraySerializer
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationEventPublisherAware,org.springframework.core.serializer.Deserializer<byte[]>,org.springframework.core.serializer.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
-
Field Summary
Fields inherited from class org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer
DEFAULT_MAX_MESSAGE_SIZE, logger -
Constructor Summary
Constructors Constructor Description AbstractPooledBufferByteArraySerializer() -
Method Summary
Modifier and Type Method Description protected byte[]copyToSizedArray(byte[] buffer, int size)Copy size bytes to a new buffer exactly size bytes long.byte[]deserialize(java.io.InputStream inputStream)protected abstract byte[]doDeserialize(java.io.InputStream inputStream, byte[] buffer)voidsetPoolSize(int size)Set the pool size for deserialization buffers.voidsetPoolWaitTimeout(long poolWaitTimeout)Set the pool wait timeout if a pool is configured, default unlimited.Methods inherited from class org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer
checkClosure, getMaxMessageSize, publishEvent, setApplicationEventPublisher, setMaxMessageSizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
AbstractPooledBufferByteArraySerializer
public AbstractPooledBufferByteArraySerializer()
-
-
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(java.io.InputStream inputStream) throws java.io.IOException- Throws:
java.io.IOException
-
doDeserialize
protected abstract byte[] doDeserialize(java.io.InputStream inputStream, byte[] buffer) throws java.io.IOException- Parameters:
inputStream- the input stream.buffer- the raw working buffer (maxMessageSize).- Returns:
- the decoded bytes.
- Throws:
java.io.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.
-