Class ImmediateSingleObjectBody
java.lang.Object
io.micronaut.http.server.netty.body.ImmediateSingleObjectBody
- All Implemented Interfaces:
HttpBody
,MultiObjectBody
@Internal
public final class ImmediateSingleObjectBody
extends Object
implements HttpBody, MultiObjectBody
HttpBody
that contains a single object. This is used to implement
NettyHttpRequest.getBody()
and CompletableFuture
binding.- Since:
- 4.0.0
- Author:
- Jonas Konrad
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionPublisher<?>
Get this value as a publisher.Get the value and transfer ownership to the caller.coerceToInputStream
(io.netty.buffer.ByteBufAllocator alloc) Coerce this value to anInputStream
.convert
(ConversionService conversionService, ArgumentConversionContext<?> context) void
handleForm
(FormRouteCompleter formRouteCompleter) Special handling for form data.mapNotNull
(Function<Object, Object> transform) Apply a mapping function to all objects in this body.next()
Get the next representation this body was transformed into, if any.final void
release()
Release this body and any downstream representations.Get the value without transferring ownership.
-
Constructor Details
-
ImmediateSingleObjectBody
-
-
Method Details
-
claimForExternal
Get the value and transfer ownership to the caller. The caller must release the value after it's done. Can only be called once.- Returns:
- The claimed value
-
valueUnclaimed
Get the value without transferring ownership. The returned value may become invalid when other code callsclaimForExternal()
or when the netty request is destroyed.- Returns:
- The unclaimed value
-
convert
public Optional<ImmediateSingleObjectBody> convert(ConversionService conversionService, ArgumentConversionContext<?> context) -
coerceToInputStream
Description copied from interface:MultiObjectBody
Coerce this value to anInputStream
. This implementsNettyInputStreamBodyBinder
. Requires the objects of this body to beByteBuf
s.
Ownership is transferred to the stream, it must be closed to release all buffers.- Specified by:
coerceToInputStream
in interfaceMultiObjectBody
- Parameters:
alloc
- The buffer allocator to use- Returns:
- The stream that reads the data in this body
-
asPublisher
Description copied from interface:MultiObjectBody
Get this value as a publisher. The publisher must be subscribed to exactly once. All objects forwarded to the subscriber become its responsibility and must be released by the subscriber.- Specified by:
asPublisher
in interfaceMultiObjectBody
- Returns:
- The publisher
-
mapNotNull
Description copied from interface:MultiObjectBody
Apply a mapping function to all objects in this body.null
values in the output are skipped.- Specified by:
mapNotNull
in interfaceMultiObjectBody
- Parameters:
transform
- The mapping function- Returns:
- A new body with the mapped values
-
handleForm
Description copied from interface:MultiObjectBody
Special handling for form data. This method basically acts likeasPublisher().subscribe(formRouteCompleter)
. However,FormRouteCompleter
needs to release the form data fields when the request is destroyed. To do this, it implementsHttpBody.release()
. By calling this method, theFormRouteCompleter
is registered as thenext body
and will be released.- Specified by:
handleForm
in interfaceMultiObjectBody
- Parameters:
formRouteCompleter
- The form route completer that should take over processing
-
release
public final void release()Description copied from interface:HttpBody
Release this body and any downstream representations. -
next
Description copied from interface:HttpBody
Get the next representation this body was transformed into, if any.
-