Package io.micronaut.http.netty.body
Class NettyWritableBodyWriter
java.lang.Object
io.micronaut.http.netty.body.NettyWritableBodyWriter
- All Implemented Interfaces:
ChunkedMessageBodyReader<Writable>
,MessageBodyHandler<Writable>
,MessageBodyReader<Writable>
,MessageBodyWriter<Writable>
,RawMessageBodyHandler<Writable>
,NettyBodyWriter<Writable>
@Replaces(WritableBodyWriter.class)
@Singleton
@Internal
@Bean(typed=RawMessageBodyHandler.class)
public final class NettyWritableBodyWriter
extends Object
implements NettyBodyWriter<Writable>, RawMessageBodyHandler<Writable>
Netty-specific writer implementation.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCollection<? extends Class<?>>
getTypes()
Supported types of this raw body handler.boolean
true
iff this closure can do a blocking read on the object it receives.Reads an object from the given byte buffer.readChunked
(Argument<Writable> type, MediaType mediaType, Headers httpHeaders, Publisher<ByteBuffer<?>> input) void
writeTo
(Argument<Writable> type, MediaType mediaType, Writable object, MutableHeaders outgoingHeaders, OutputStream outputStream) Writes an object to the given output stream.void
writeTo
(HttpRequest<?> request, MutableHttpResponse<Writable> outgoingResponse, Argument<Writable> type, MediaType mediaType, Writable object, NettyWriteContext nettyContext) Write an object to the given context.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.MessageBodyReader
isReadable, read
Methods inherited from interface io.micronaut.http.body.MessageBodyWriter
createSpecific, isWriteable, writeTo
-
Constructor Details
-
NettyWritableBodyWriter
-
-
Method Details
-
isBlocking
public boolean isBlocking()Description copied from interface:MessageBodyWriter
true
iff this closure can do a blocking read on the object it receives. For example, if this closure writes from anInputStream
, that operation may be blocking and this method returnstrue
.
Note that even when this isfalse
,MessageBodyWriter.writeTo(Argument, MediaType, Object, MutableHeaders, OutputStream)
may still block because theOutputStream
that is passed as the write destination may still block.- Specified by:
isBlocking
in interfaceMessageBodyWriter<Writable>
- Returns:
- Whether this writer may block
-
writeTo
public void writeTo(HttpRequest<?> request, MutableHttpResponse<Writable> outgoingResponse, Argument<Writable> type, MediaType mediaType, Writable object, NettyWriteContext nettyContext) throws CodecException Description copied from interface:NettyBodyWriter
Write an object to the given context.- Specified by:
writeTo
in interfaceNettyBodyWriter<Writable>
- Parameters:
request
- The associated requestoutgoingResponse
- The outgoing response.type
- The typemediaType
- The media typeobject
- The object to writenettyContext
- The netty context- Throws:
CodecException
- If an error occurs decoding
-
writeTo
public void writeTo(Argument<Writable> type, MediaType mediaType, Writable 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<Writable>
- Parameters:
type
- The typemediaType
- The media typeobject
- The object to writeoutgoingHeaders
- The HTTP headersoutputStream
- The output stream- Throws:
CodecException
- If an error occurs decoding
-
readChunked
public Publisher<? extends Writable> readChunked(Argument<Writable> type, MediaType mediaType, Headers httpHeaders, Publisher<ByteBuffer<?>> input) - Specified by:
readChunked
in interfaceChunkedMessageBodyReader<Writable>
-
read
public Writable read(Argument<Writable> 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<Writable>
- 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
-
getTypes
Description copied from interface:RawMessageBodyHandler
Supported types of this raw body handler. Exact match is used for reading. For writing, the match is covariant. For example, if this returns[String, CharSequence]
, then this raw handler will be used for reading types declared as exactlyString
orCharSequence
, and will additionally be used for writing (but not reading) subtypes (e.g.StringBuilder
).- Specified by:
getTypes
in interfaceRawMessageBodyHandler<Writable>
- Returns:
- The supported types
-