Package io.micronaut.buffer.netty
Class NettyByteBufferFactory
java.lang.Object
io.micronaut.buffer.netty.NettyByteBufferFactory
- All Implemented Interfaces:
TypeConverterRegistrar
,ByteBufferFactory<io.netty.buffer.ByteBufAllocator,
io.netty.buffer.ByteBuf>
@Internal
@Singleton
public final class NettyByteBufferFactory
extends Object
implements ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>, TypeConverterRegistrar
A
ByteBufferFactory
implementation for Netty.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Modifier and TypeFieldDescriptionstatic final NettyByteBufferFactory
Default Netty ByteBuffer Factory. -
Constructor Summary
ConstructorDescriptionDefault constructor.NettyByteBufferFactory
(io.netty.buffer.ByteBufAllocator allocator) -
Method Summary
Modifier and TypeMethodDescriptionByteBuffer<io.netty.buffer.ByteBuf>
buffer()
Allocate aByteBuffer
.ByteBuffer<io.netty.buffer.ByteBuf>
buffer
(int initialCapacity) Allocate aByteBuffer
with the given initial capacity.ByteBuffer<io.netty.buffer.ByteBuf>
buffer
(int initialCapacity, int maxCapacity) Allocate aByteBuffer
with the given initial capacity and the given maximal capacity.ByteBuffer<io.netty.buffer.ByteBuf>
copiedBuffer
(byte[] bytes) Creates a new big-endian buffer whose content is a copy of the specifiedarray
's sub-region.ByteBuffer<io.netty.buffer.ByteBuf>
copiedBuffer
(ByteBuffer nioBuffer) Creates a new big-endian buffer whose content is a copy of the specified NIO buffer.io.netty.buffer.ByteBufAllocator
void
register
(MutableConversionService conversionService) Interface for registrars ofTypeConverter
instances.ByteBuffer<io.netty.buffer.ByteBuf>
wrap
(byte[] existing) Wrap an existing buffer.ByteBuffer<io.netty.buffer.ByteBuf>
wrap
(io.netty.buffer.ByteBuf existing) Wrap an existing buffer.
-
Field Details
-
DEFAULT
Default Netty ByteBuffer Factory.
-
-
Constructor Details
-
NettyByteBufferFactory
public NettyByteBufferFactory()Default constructor. -
NettyByteBufferFactory
public NettyByteBufferFactory(io.netty.buffer.ByteBufAllocator allocator) - Parameters:
allocator
- TheByteBufAllocator
-
-
Method Details
-
register
Description copied from interface:TypeConverterRegistrar
Interface for registrars ofTypeConverter
instances.- Specified by:
register
in interfaceTypeConverterRegistrar
- Parameters:
conversionService
- TheConversionService
-
getNativeAllocator
public io.netty.buffer.ByteBufAllocator getNativeAllocator()- Specified by:
getNativeAllocator
in interfaceByteBufferFactory<io.netty.buffer.ByteBufAllocator,
io.netty.buffer.ByteBuf> - Returns:
- The native allocator
-
buffer
Description copied from interface:ByteBufferFactory
Allocate aByteBuffer
. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
buffer
in interfaceByteBufferFactory<io.netty.buffer.ByteBufAllocator,
io.netty.buffer.ByteBuf> - Returns:
- The buffer
-
buffer
Description copied from interface:ByteBufferFactory
Allocate aByteBuffer
with the given initial capacity. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
buffer
in interfaceByteBufferFactory<io.netty.buffer.ByteBufAllocator,
io.netty.buffer.ByteBuf> - Parameters:
initialCapacity
- The initial capacity- Returns:
- the buffer
-
buffer
Description copied from interface:ByteBufferFactory
Allocate aByteBuffer
with the given initial capacity and the given maximal capacity. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
buffer
in interfaceByteBufferFactory<io.netty.buffer.ByteBufAllocator,
io.netty.buffer.ByteBuf> - Parameters:
initialCapacity
- The initial capacitymaxCapacity
- The maximum capacity- Returns:
- The buffer
-
copiedBuffer
Description copied from interface:ByteBufferFactory
Creates a new big-endian buffer whose content is a copy of the specifiedarray
's sub-region. The new buffer'sreaderIndex
andwriterIndex
are0
and the specifiedlength
respectively.- Specified by:
copiedBuffer
in interfaceByteBufferFactory<io.netty.buffer.ByteBufAllocator,
io.netty.buffer.ByteBuf> - Parameters:
bytes
- The bytes- Returns:
- The buffer
-
copiedBuffer
Description copied from interface:ByteBufferFactory
Creates a new big-endian buffer whose content is a copy of the specified NIO buffer. The new buffer'sreaderIndex
andwriterIndex
are0
and the specifiedlength
respectively.- Specified by:
copiedBuffer
in interfaceByteBufferFactory<io.netty.buffer.ByteBufAllocator,
io.netty.buffer.ByteBuf> - Parameters:
nioBuffer
- The nioBuffer- Returns:
- The buffer
-
wrap
Description copied from interface:ByteBufferFactory
Wrap an existing buffer.- Specified by:
wrap
in interfaceByteBufferFactory<io.netty.buffer.ByteBufAllocator,
io.netty.buffer.ByteBuf> - Parameters:
existing
- The buffer to wrap- Returns:
- The wrapped
ByteBuffer
-
wrap
Description copied from interface:ByteBufferFactory
Wrap an existing buffer.- Specified by:
wrap
in interfaceByteBufferFactory<io.netty.buffer.ByteBufAllocator,
io.netty.buffer.ByteBuf> - Parameters:
existing
- The bytes to wrap- Returns:
- The wrapped
ByteBuffer
-