public class NettyDataBufferFactory extends Object implements DataBufferFactory
DataBufferFactory interface based on a
 Netty ByteBufAllocator.PooledByteBufAllocator, 
UnpooledByteBufAllocator| Constructor and Description | 
|---|
| NettyDataBufferFactory(io.netty.buffer.ByteBufAllocator byteBufAllocator)Create a new  NettyDataBufferFactorybased on the given factory. | 
| Modifier and Type | Method and Description | 
|---|---|
| NettyDataBuffer | allocateBuffer()Allocate a data buffer of a default initial capacity. | 
| NettyDataBuffer | allocateBuffer(int initialCapacity)Allocate a data buffer of the given initial capacity. | 
| io.netty.buffer.ByteBufAllocator | getByteBufAllocator()Return the  ByteBufAllocatorused by this factory. | 
| DataBuffer | join(List<? extends DataBuffer> dataBuffers)Return a new  DataBuffercomposed of thedataBufferselements joined together. | 
| static io.netty.buffer.ByteBuf | toByteBuf(DataBuffer buffer)Return the given Netty  DataBufferas aByteBuf. | 
| String | toString() | 
| DataBuffer | wrap(byte[] bytes)Wrap the given  bytearray in aDataBuffer. | 
| NettyDataBuffer | wrap(io.netty.buffer.ByteBuf byteBuf)Wrap the given Netty  ByteBufin aNettyDataBuffer. | 
| NettyDataBuffer | wrap(ByteBuffer byteBuffer)Wrap the given  ByteBufferin aDataBuffer. | 
public NettyDataBufferFactory(io.netty.buffer.ByteBufAllocator byteBufAllocator)
NettyDataBufferFactory based on the given factory.byteBufAllocator - the factory to usePooledByteBufAllocator, 
UnpooledByteBufAllocatorpublic io.netty.buffer.ByteBufAllocator getByteBufAllocator()
ByteBufAllocator used by this factory.public NettyDataBuffer allocateBuffer()
DataBufferFactoryallocateBuffer in interface DataBufferFactorypublic NettyDataBuffer allocateBuffer(int initialCapacity)
DataBufferFactoryallocateBuffer in interface DataBufferFactoryinitialCapacity - the initial capacity of the buffer to allocatepublic NettyDataBuffer wrap(ByteBuffer byteBuffer)
DataBufferFactorywrap in interface DataBufferFactorybyteBuffer - the NIO byte buffer to wrappublic DataBuffer wrap(byte[] bytes)
DataBufferFactorywrap in interface DataBufferFactorybytes - the byte array to wrappublic NettyDataBuffer wrap(io.netty.buffer.ByteBuf byteBuf)
ByteBuf in a NettyDataBuffer.byteBuf - the Netty byte buffer to wrappublic DataBuffer join(List<? extends DataBuffer> dataBuffers)
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 CompositeByteBuf.
join in interface DataBufferFactorydataBuffers - the data buffers to be composeddataBuffers argumentpublic static io.netty.buffer.ByteBuf toByteBuf(DataBuffer buffer)
DataBuffer as a ByteBuf.
 Returns the native buffer
 if buffer is a NettyDataBuffer; returns
 Unpooled.wrappedBuffer(ByteBuffer) otherwise.
buffer - the DataBuffer to return a ByteBuf forByteBuf