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>
,ResponseBodyWriter<Writable>
,TypedMessageBodyHandler<Writable>
,TypedMessageBodyReader<Writable>
,TypedMessageBodyWriter<Writable>
@Replaces(WritableBodyWriter.class)
@Singleton
@Internal
public final class NettyWritableBodyWriter
extends Object
implements TypedMessageBodyHandler<Writable>, ChunkedMessageBodyReader<Writable>, ResponseBodyWriter<Writable>
Netty-specific writer implementation.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetType()
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) write
(ByteBufferFactory<?, ?> bufferFactory, HttpRequest<?> request, MutableHttpResponse<Writable> outgoingResponse, Argument<Writable> type, MediaType mediaType, Writable object) Writes an object as aByteBodyHttpResponse
.void
writeTo
(Argument<Writable> type, MediaType mediaType, Writable 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.MessageBodyReader
read
Methods inherited from interface io.micronaut.http.body.MessageBodyWriter
createSpecific, writeTo
Methods inherited from interface io.micronaut.http.body.TypedMessageBodyReader
isReadable
Methods inherited from interface io.micronaut.http.body.TypedMessageBodyWriter
isWriteable
-
Constructor Details
-
NettyWritableBodyWriter
-
-
Method Details
-
getType
- Specified by:
getType
in interfaceTypedMessageBodyHandler<Writable>
- Specified by:
getType
in interfaceTypedMessageBodyReader<Writable>
- Specified by:
getType
in interfaceTypedMessageBodyWriter<Writable>
- Returns:
- The body type.
-
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
-
write
public ByteBodyHttpResponse<?> write(ByteBufferFactory<?, ?> bufferFactory, HttpRequest<?> request, MutableHttpResponse<Writable> outgoingResponse, Argument<Writable> type, MediaType mediaType, Writable object) throws CodecExceptionDescription copied from interface:ResponseBodyWriter
Writes an object as aByteBodyHttpResponse
.- Specified by:
write
in interfaceResponseBodyWriter<Writable>
- Parameters:
bufferFactory
- The buffer factoryrequest
- The requestoutgoingResponse
- The responsetype
- The response body typemediaType
- The media typeobject
- The object to write- Returns:
- A
ByteBodyHttpResponse
with the response bytes - Throws:
CodecException
- If an error occurs encoding
-
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
-