Package io.micronaut.http.body
Class DynamicMessageBodyWriter
java.lang.Object
io.micronaut.http.body.DynamicMessageBodyWriter
- All Implemented Interfaces:
MessageBodyWriter<Object>
@Internal
public final class DynamicMessageBodyWriter
extends Object
implements MessageBodyWriter<Object>
Placeholder
MessageBodyWriter
implementation that decides which writer to use based on
the dynamic (runtime) type of the body. Used as fallback where the type is not known statically.- Since:
- 4.0.0
- Author:
- Jonas Konrad
-
Constructor Summary
ConstructorDescriptionDynamicMessageBodyWriter
(MessageBodyHandlerRegistry registry, List<MediaType> mediaTypes) -
Method Summary
Modifier and TypeMethodDescriptioncreateSpecific
(Argument<Object> type) Prepare aMessageBodyWriter
that will write the given type.ByteBuffer<?>
writeTo
(Argument<Object> type, MediaType mediaType, Object object, MutableHeaders outgoingHeaders, ByteBufferFactory<?, ?> bufferFactory) Writes an object to the given stream.void
writeTo
(Argument<Object> type, MediaType mediaType, Object 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
isBlocking, isWriteable
-
Constructor Details
-
DynamicMessageBodyWriter
-
-
Method Details
-
createSpecific
Description copied from interface:MessageBodyWriter
Prepare aMessageBodyWriter
that will write the given type. This can be used for precomputing some route data.- Specified by:
createSpecific
in interfaceMessageBodyWriter<Object>
- Parameters:
type
- The type- Returns:
- The closure
-
find
-
writeTo
public void writeTo(Argument<Object> type, MediaType mediaType, Object 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<Object>
- 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<Object> type, MediaType mediaType, Object object, MutableHeaders outgoingHeaders, ByteBufferFactory<?, ?> bufferFactory) throws CodecExceptionDescription copied from interface:MessageBodyWriter
Writes an object to the given stream.- Specified by:
writeTo
in interfaceMessageBodyWriter<Object>
- 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
-