Class Netty5DataBufferFactory
java.lang.Object
org.springframework.core.io.buffer.Netty5DataBufferFactory
- All Implemented Interfaces:
DataBufferFactory
Implementation of the
DataBufferFactory interface based on a
Netty 5 BufferAllocator.- Since:
- 6.0
- Author:
- Violeta Georgieva, Arjen Poutsma
-
Constructor Summary
ConstructorsConstructorDescriptionNetty5DataBufferFactory(io.netty5.buffer.BufferAllocator bufferAllocator) Create a newNetty5DataBufferFactorybased on the given factory. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.allocateBuffer(int initialCapacity) Allocate a data buffer of the given initial capacity.io.netty5.buffer.BufferAllocatorReturn theBufferAllocatorused by this factory.booleanisDirect()Indicates whether this factory allocates direct buffers (i.e.join(List<? extends DataBuffer> dataBuffers) Return a newDataBuffercomposed of thedataBufferselements joined together.static io.netty5.buffer.BuffertoBuffer(DataBuffer buffer) Return the given NettyDataBufferas aBuffer.toString()wrap(byte[] bytes) Wrap the givenbytearray in aDataBuffer.wrap(io.netty5.buffer.Buffer buffer) Wrap the given NettyBufferin aNetty5DataBuffer.wrap(ByteBuffer byteBuffer) Wrap the givenByteBufferin aDataBuffer.
-
Constructor Details
-
Netty5DataBufferFactory
public Netty5DataBufferFactory(io.netty5.buffer.BufferAllocator bufferAllocator) Create a newNetty5DataBufferFactorybased on the given factory.- Parameters:
bufferAllocator- the factory to use
-
-
Method Details
-
getBufferAllocator
public io.netty5.buffer.BufferAllocator getBufferAllocator()Return theBufferAllocatorused by this factory. -
allocateBuffer
Deprecated.Description copied from interface:DataBufferFactoryAllocate a data buffer of a default initial capacity. Depending on the underlying implementation and its configuration, this will be heap-based or direct buffer.- Specified by:
allocateBufferin interfaceDataBufferFactory- Returns:
- the allocated buffer
-
allocateBuffer
Description copied from interface:DataBufferFactoryAllocate a data buffer of the given initial capacity. Depending on the underlying implementation and its configuration, this will be heap-based or direct buffer.- Specified by:
allocateBufferin interfaceDataBufferFactory- Parameters:
initialCapacity- the initial capacity of the buffer to allocate- Returns:
- the allocated buffer
-
wrap
Description copied from interface:DataBufferFactory- Specified by:
wrapin interfaceDataBufferFactory- Parameters:
byteBuffer- the NIO byte buffer to wrap- Returns:
- the wrapped buffer
-
wrap
Description copied from interface:DataBufferFactory- Specified by:
wrapin interfaceDataBufferFactory- Parameters:
bytes- the byte array to wrap- Returns:
- the wrapped buffer
-
wrap
Wrap the given NettyBufferin aNetty5DataBuffer.- Parameters:
buffer- the Netty buffer to wrap- Returns:
- the wrapped buffer
-
join
Return a newDataBuffercomposed of thedataBufferselements joined together. Depending on the implementation, the returned buffer may be a single buffer containing all data of the provided buffers, or it may be a true composite that contains references to the buffers.Note that the given data buffers do not have to be released, as they are released as part of the returned composite.
This implementation uses Netty's
CompositeBuffer.- Specified by:
joinin interfaceDataBufferFactory- Parameters:
dataBuffers- the data buffers to be composed- Returns:
- a buffer that is composed of the
dataBuffersargument
-
isDirect
public boolean isDirect()Description copied from interface:DataBufferFactoryIndicates whether this factory allocates direct buffers (i.e. non-heap, native memory).- Specified by:
isDirectin interfaceDataBufferFactory- Returns:
trueif this factory allocates direct buffers;falseotherwise
-
toBuffer
Return the given NettyDataBufferas aBuffer.Returns the native buffer if
bufferis aNetty5DataBuffer; returnsBufferAllocator.copyOf(ByteBuffer)otherwise.- Parameters:
buffer- theDataBufferto return aBufferfor- Returns:
- the netty
Buffer
-
toString
-