Package io.micronaut.http.netty.body
Class NettyJsonStreamHandler<T>
java.lang.Object
io.micronaut.http.netty.body.NettyJsonStreamHandler<T>
- Type Parameters:
T
- The type
- All Implemented Interfaces:
ChunkedMessageBodyReader<T>
,MessageBodyHandler<T>
,MessageBodyReader<T>
,MessageBodyWriter<T>
,CustomizableJsonHandler
@Internal
@Singleton
@Produces("application/x-json-stream")
@Consumes("application/x-json-stream")
public final class NettyJsonStreamHandler<T>
extends Object
implements MessageBodyHandler<T>, ChunkedMessageBodyReader<T>, CustomizableJsonHandler
Netty json stream implementation for MessageBodyHandler.
- Since:
- 4.0.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncustomize
(JsonFeatures jsonFeatures) boolean
isReadable
(Argument<T> type, MediaType mediaType) Is the type readable.Reads an object from the given byte buffer.Reads an object from the given byte buffer.reactor.core.publisher.Flux<T>
readChunked
(Argument<T> type, MediaType mediaType, Headers httpHeaders, Publisher<ByteBuffer<?>> input) ByteBuffer<?>
writeTo
(Argument<T> type, MediaType mediaType, T object, MutableHeaders outgoingHeaders, ByteBufferFactory<?, ?> bufferFactory) Writes an object to the given stream.void
writeTo
(Argument<T> type, MediaType mediaType, T object, MutableHeaders outgoingHeaders, OutputStream outputStream) Writes an object to the given output stream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.http.body.MessageBodyWriter
createSpecific, isBlocking, isWriteable
-
Constructor Details
-
NettyJsonStreamHandler
-
-
Method Details
-
customize
- Specified by:
customize
in interfaceCustomizableJsonHandler
-
isReadable
Description copied from interface:MessageBodyReader
Is the type readable.- Specified by:
isReadable
in interfaceMessageBodyReader<T>
- Parameters:
type
- The typemediaType
- The media type, can benull
- Returns:
- True if is readable
-
read
public T read(Argument<T> type, MediaType mediaType, Headers httpHeaders, ByteBuffer<?> byteBuffer) throws CodecException Description copied from interface:MessageBodyReader
Reads an object from the given byte buffer.- Specified by:
read
in interfaceMessageBodyReader<T>
- Parameters:
type
- The type being decoded.mediaType
- The media type, can benull
httpHeaders
- The HTTP headersbyteBuffer
- The byte buffer- Returns:
- The read object or
null
- Throws:
CodecException
- If an error occurs decoding
-
read
public T read(Argument<T> type, MediaType mediaType, Headers httpHeaders, InputStream inputStream) throws CodecException Description copied from interface:MessageBodyReader
Reads an object from the given byte buffer.- Specified by:
read
in interfaceMessageBodyReader<T>
- Parameters:
type
- The type being decoded.mediaType
- The media type, can benull
httpHeaders
- The HTTP headersinputStream
- The input stream- Returns:
- The read object or
null
- Throws:
CodecException
- If an error occurs decoding
-
readChunked
public reactor.core.publisher.Flux<T> readChunked(Argument<T> type, MediaType mediaType, Headers httpHeaders, Publisher<ByteBuffer<?>> input) - Specified by:
readChunked
in interfaceChunkedMessageBodyReader<T>
-
writeTo
public void writeTo(Argument<T> type, MediaType mediaType, T object, MutableHeaders outgoingHeaders, OutputStream outputStream) throws CodecException Description copied from interface:MessageBodyWriter
Writes an object to the given output stream.- Specified by:
writeTo
in interfaceMessageBodyWriter<T>
- Parameters:
type
- The typemediaType
- The media typeobject
- The object to writeoutgoingHeaders
- The HTTP headersoutputStream
- The output stream- Throws:
CodecException
- If an error occurs decoding
-
writeTo
public ByteBuffer<?> writeTo(Argument<T> type, MediaType mediaType, T object, MutableHeaders outgoingHeaders, ByteBufferFactory<?, ?> bufferFactory) throws CodecExceptionDescription copied from interface:MessageBodyWriter
Writes an object to the given stream.- Specified by:
writeTo
in interfaceMessageBodyWriter<T>
- Parameters:
type
- The typemediaType
- The media typeobject
- The object to writeoutgoingHeaders
- The HTTP headersbufferFactory
- A byte buffer factory- Returns:
- The encoded byte buffer
- Throws:
CodecException
- If an error occurs decoding
-