Top Description Fields Constructors Methods
org.springframework.core.io.buffer

public Class Netty5DataBufferFactory

extends Object
implements DataBufferFactory
Class Inheritance
All Implemented Interfaces
org.springframework.core.io.buffer.DataBufferFactory
Imports
java.nio.ByteBuffer, java.util.List, io.netty5.buffer.Buffer, .BufferAllocator, .CompositeBuffer, .DefaultBufferAllocators, org.springframework.util.Assert

Implementation of the DataBufferFactory interface based on a Netty 5 BufferAllocator.
Authors
Violeta Georgieva, Arjen Poutsma
Since
6.0

Field Summary

Modifier and TypeField and Description
private final BufferAllocator

Constructor Summary

AccessConstructor and Description
public
Netty5DataBufferFactory(BufferAllocator
the factory to use
bufferAllocator
)

Create a new Netty5DataBufferFactory based on the given factory.

Method Summary

Modifier and TypeMethod and Description
public Netty5DataBuffer
allocateBuffer()

Implements org.springframework.core.io.buffer.DataBufferFactory.allocateBuffer.

Deprecated

Allocate a data buffer of a default initial capacity.

public Netty5DataBuffer
allocateBuffer(int
the initial capacity of the buffer to allocate
initialCapacity
)

Implements org.springframework.core.io.buffer.DataBufferFactory.allocateBuffer.

Allocate a data buffer of the given initial capacity.

public BufferAllocator
getBufferAllocator()

Return the BufferAllocator used by this factory.

public boolean
isDirect()

Implements org.springframework.core.io.buffer.DataBufferFactory.isDirect.

Indicates whether this factory allocates direct buffers (i.e. non-heap, native memory).

public DataBuffer
join(List<? extends DataBuffer>
the data buffers to be composed
dataBuffers
)

Implements org.springframework.core.io.buffer.DataBufferFactory.join.

Return a new DataBuffer composed of the dataBuffers elements joined together.

public static Buffer

Returns:

the netty Buffer
toBuffer
(DataBuffer
the DataBuffer to return a Buffer for
buffer
)

Return the given Netty DataBuffer as a Buffer.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public Netty5DataBuffer
wrap(ByteBuffer
the NIO byte buffer to wrap
byteBuffer
)

Implements org.springframework.core.io.buffer.DataBufferFactory.wrap.

Wrap the given ByteBuffer in a DataBuffer.

public Netty5DataBuffer
wrap(byte[]
the byte array to wrap
bytes
)

Implements org.springframework.core.io.buffer.DataBufferFactory.wrap.

Wrap the given byte array in a DataBuffer.

public Netty5DataBuffer

Returns:

the wrapped buffer
wrap
(Buffer
the Netty buffer to wrap
buffer
)

Wrap the given Netty Buffer in a Netty5DataBuffer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

bufferAllocatorback to summary
private final BufferAllocator bufferAllocator

Constructor Detail

Netty5DataBufferFactoryback to summary
public Netty5DataBufferFactory(BufferAllocator bufferAllocator)

Create a new Netty5DataBufferFactory based on the given factory.

Parameters
bufferAllocator:BufferAllocator

the factory to use

Method Detail

allocateBufferback to summary
public Netty5DataBuffer allocateBuffer()

Implements org.springframework.core.io.buffer.DataBufferFactory.allocateBuffer.

Doc from org.springframework.core.io.buffer.DataBufferFactory.allocateBuffer.

Deprecated

Allocate a data buffer of a default initial capacity. Depending on the underlying implementation and its configuration, this will be heap-based or direct buffer.

Returns:Netty5DataBuffer

the allocated buffer

Annotations
@Override
@Deprecated
allocateBufferback to summary
public Netty5DataBuffer allocateBuffer(int initialCapacity)

Implements org.springframework.core.io.buffer.DataBufferFactory.allocateBuffer.

Doc from org.springframework.core.io.buffer.DataBufferFactory.allocateBuffer.

Allocate a data buffer of the given initial capacity. Depending on the underlying implementation and its configuration, this will be heap-based or direct buffer.

Parameters
initialCapacity:int

the initial capacity of the buffer to allocate

Returns:Netty5DataBuffer

the allocated buffer

Annotations
@Override
getBufferAllocatorback to summary
public BufferAllocator getBufferAllocator()

Return the BufferAllocator used by this factory.

isDirectback to summary
public boolean isDirect()

Implements org.springframework.core.io.buffer.DataBufferFactory.isDirect.

Doc from org.springframework.core.io.buffer.DataBufferFactory.isDirect.

Indicates whether this factory allocates direct buffers (i.e. non-heap, native memory).

Returns:boolean

true if this factory allocates direct buffers; false otherwise

Annotations
@Override
joinback to summary
public DataBuffer join(List<? extends DataBuffer> dataBuffers)

Implements org.springframework.core.io.buffer.DataBufferFactory.join.

Doc from org.springframework.core.io.buffer.DataBufferFactory.join.

Return a new DataBuffer composed of the dataBuffers elements 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.

Parameters
dataBuffers:List<? extends DataBuffer>

the data buffers to be composed

Returns:DataBuffer

a buffer that is composed of the dataBuffers argument

Annotations
@Override
toBufferback to summary
public static Buffer toBuffer(DataBuffer buffer)

Return the given Netty DataBuffer as a Buffer.

Returns the native buffer if buffer is a Netty5DataBuffer; returns BufferAllocator#copyOf(ByteBuffer) otherwise.

Parameters
buffer:DataBuffer

the DataBuffer to return a Buffer for

Returns:Buffer

the netty Buffer

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
wrapback to summary
public Netty5DataBuffer wrap(ByteBuffer byteBuffer)

Implements org.springframework.core.io.buffer.DataBufferFactory.wrap.

Doc from org.springframework.core.io.buffer.DataBufferFactory.wrap.

Wrap the given ByteBuffer in a DataBuffer. Unlike allocating, wrapping does not use new memory.

Parameters
byteBuffer:ByteBuffer

the NIO byte buffer to wrap

Returns:Netty5DataBuffer

the wrapped buffer

Annotations
@Override
wrapback to summary
public Netty5DataBuffer wrap(byte[] bytes)

Implements org.springframework.core.io.buffer.DataBufferFactory.wrap.

Doc from org.springframework.core.io.buffer.DataBufferFactory.wrap.

Wrap the given byte array in a DataBuffer. Unlike allocating, wrapping does not use new memory.

Parameters
bytes:byte[]

the byte array to wrap

Returns:Netty5DataBuffer

the wrapped buffer

Annotations
@Override
wrapback to summary
public Netty5DataBuffer wrap(Buffer buffer)

Wrap the given Netty Buffer in a Netty5DataBuffer.

Parameters
buffer:Buffer

the Netty buffer to wrap

Returns:Netty5DataBuffer

the wrapped buffer