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
Base class for deserializers that cannot determine the buffer size needed.
Optionally pools buffers.
- Since:
- 4.3
- Author:
- Gary Russell, Ngoc Nhan
-
Field Summary
Fields inherited from class org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer
DEFAULT_MAX_MESSAGE_SIZE, logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]
copyToSizedArray
(byte[] buffer, int size) Copy size bytes to a new buffer exactly size bytes long.final byte[]
deserialize
(InputStream inputStream) protected abstract byte[]
doDeserialize
(InputStream inputStream, byte[] buffer) void
setPoolSize
(int size) Set the pool size for deserialization buffers.void
setPoolWaitTimeout
(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, setMaxMessageSize
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.core.serializer.Deserializer
deserializeFromByteArray
Methods inherited from interface org.springframework.core.serializer.Serializer
serialize, serializeToByteArray
-
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
- Throws:
IOException
-
doDeserialize
- 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.
-