java.lang.Object
io.jooby.netty.buffer.NettyDataBufferFactory
- All Implemented Interfaces:
DataBufferFactory
Implementation of the
DataBufferFactory interface based on a Netty 4 ByteBufAllocator.- Since:
- 5.0
- Author:
- Arjen Poutsma, Juergen Hoeller
- See Also:
-
PooledByteBufAllocatorUnpooledByteBufAllocator
-
Constructor Summary
ConstructorsConstructorDescriptionNettyDataBufferFactory(io.netty.buffer.ByteBufAllocator byteBufAllocator) Create a newNettyDataBufferFactorybased on the given factory. -
Method Summary
Modifier and TypeMethodDescriptionallocateBuffer(int initialCapacity) io.netty.buffer.ByteBufAllocatorReturn theByteBufAllocatorused by this factory.intbooleanisDirect()join(List<? extends DataBuffer> dataBuffers) setDefaultInitialCapacity(int defaultInitialCapacity) static io.netty.buffer.ByteBuftoByteBuf(DataBuffer dataBuffer) Return the given NettyDataBufferas aByteBuf.toString()wrap(byte[] bytes) wrap(byte[] bytes, int offset, int length) wrap(io.netty.buffer.ByteBuf byteBuf) Wrap the given NettyByteBufin aNettyDataBuffer.wrap(ByteBuffer byteBuffer)
-
Constructor Details
-
NettyDataBufferFactory
public NettyDataBufferFactory(io.netty.buffer.ByteBufAllocator byteBufAllocator) Create a newNettyDataBufferFactorybased on the given factory.- Parameters:
byteBufAllocator- the factory to use- See Also:
-
PooledByteBufAllocatorUnpooledByteBufAllocator
-
NettyDataBufferFactory
public NettyDataBufferFactory()
-
-
Method Details
-
getByteBufAllocator
public io.netty.buffer.ByteBufAllocator getByteBufAllocator()Return theByteBufAllocatorused by this factory. -
getDefaultInitialCapacity
public int getDefaultInitialCapacity()- Specified by:
getDefaultInitialCapacityin interfaceDataBufferFactory
-
setDefaultInitialCapacity
- Specified by:
setDefaultInitialCapacityin interfaceDataBufferFactory
-
allocateBuffer
- Specified by:
allocateBufferin interfaceDataBufferFactory
-
allocateBuffer
- Specified by:
allocateBufferin interfaceDataBufferFactory
-
wrap
- Specified by:
wrapin interfaceDataBufferFactory
-
wrap
- Specified by:
wrapin interfaceDataBufferFactory
-
wrap
- Specified by:
wrapin interfaceDataBufferFactory
-
wrap
Wrap the given NettyByteBufin aNettyDataBuffer.- Parameters:
byteBuf- the Netty byte buffer to wrap- Returns:
- the wrapped buffer
-
join
This implementation uses Netty's
CompositeByteBuf.- Specified by:
joinin interfaceDataBufferFactory
-
isDirect
public boolean isDirect()- Specified by:
isDirectin interfaceDataBufferFactory
-
toByteBuf
Return the given NettyDataBufferas aByteBuf.Returns the native buffer if
dataBufferis aNettyDataBuffer; returnsUnpooled.wrappedBuffer(ByteBuffer)otherwise.- Parameters:
dataBuffer- theDataBufferto return aByteBuffor- Returns:
- the netty
ByteBuf
-
toString
-