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:
-
PooledByteBufAllocator
UnpooledByteBufAllocator
-
Constructor Summary
ConstructorsConstructorDescriptionNettyDataBufferFactory
(io.netty.buffer.ByteBufAllocator byteBufAllocator) Create a newNettyDataBufferFactory
based on the given factory. -
Method Summary
Modifier and TypeMethodDescriptionallocateBuffer
(int initialCapacity) io.netty.buffer.ByteBufAllocator
Return theByteBufAllocator
used by this factory.int
boolean
isDirect()
join
(List<? extends DataBuffer> dataBuffers) setDefaultInitialCapacity
(int defaultInitialCapacity) static io.netty.buffer.ByteBuf
toByteBuf
(DataBuffer dataBuffer) Return the given NettyDataBuffer
as aByteBuf
.toString()
wrap
(byte[] bytes) wrap
(byte[] bytes, int offset, int length) wrap
(io.netty.buffer.ByteBuf byteBuf) Wrap the given NettyByteBuf
in aNettyDataBuffer
.wrap
(ByteBuffer byteBuffer)
-
Constructor Details
-
NettyDataBufferFactory
public NettyDataBufferFactory(io.netty.buffer.ByteBufAllocator byteBufAllocator) Create a newNettyDataBufferFactory
based on the given factory.- Parameters:
byteBufAllocator
- the factory to use- See Also:
-
PooledByteBufAllocator
UnpooledByteBufAllocator
-
NettyDataBufferFactory
public NettyDataBufferFactory()
-
-
Method Details
-
getByteBufAllocator
public io.netty.buffer.ByteBufAllocator getByteBufAllocator()Return theByteBufAllocator
used by this factory. -
getDefaultInitialCapacity
public int getDefaultInitialCapacity()- Specified by:
getDefaultInitialCapacity
in interfaceDataBufferFactory
-
setDefaultInitialCapacity
- Specified by:
setDefaultInitialCapacity
in interfaceDataBufferFactory
-
allocateBuffer
- Specified by:
allocateBuffer
in interfaceDataBufferFactory
-
allocateBuffer
- Specified by:
allocateBuffer
in interfaceDataBufferFactory
-
wrap
- Specified by:
wrap
in interfaceDataBufferFactory
-
wrap
- Specified by:
wrap
in interfaceDataBufferFactory
-
wrap
- Specified by:
wrap
in interfaceDataBufferFactory
-
wrap
Wrap the given NettyByteBuf
in aNettyDataBuffer
.- Parameters:
byteBuf
- the Netty byte buffer to wrap- Returns:
- the wrapped buffer
-
join
This implementation uses Netty's
CompositeByteBuf
.- Specified by:
join
in interfaceDataBufferFactory
-
isDirect
public boolean isDirect()- Specified by:
isDirect
in interfaceDataBufferFactory
-
toByteBuf
Return the given NettyDataBuffer
as aByteBuf
.Returns the native buffer if
dataBuffer
is aNettyDataBuffer
; returnsUnpooled.wrappedBuffer(ByteBuffer)
otherwise.- Parameters:
dataBuffer
- theDataBuffer
to return aByteBuf
for- Returns:
- the netty
ByteBuf
-
toString
-