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
Constructors -
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) voidhandleForm(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 voidrelease()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:MultiObjectBodyCoerce this value to anInputStream. This implementsNettyInputStreamBodyBinder. Requires the objects of this body to beByteBufs.
Ownership is transferred to the stream, it must be closed to release all buffers.- Specified by:
coerceToInputStreamin interfaceMultiObjectBody- Parameters:
alloc- The buffer allocator to use- Returns:
- The stream that reads the data in this body
-
asPublisher
Description copied from interface:MultiObjectBodyGet 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:
asPublisherin interfaceMultiObjectBody- Returns:
- The publisher
-
mapNotNull
Description copied from interface:MultiObjectBodyApply a mapping function to all objects in this body.nullvalues in the output are skipped.- Specified by:
mapNotNullin interfaceMultiObjectBody- Parameters:
transform- The mapping function- Returns:
- A new body with the mapped values
-
handleForm
Description copied from interface:MultiObjectBodySpecial handling for form data. This method basically acts likeasPublisher().subscribe(formRouteCompleter). However,FormRouteCompleterneeds to release the form data fields when the request is destroyed. To do this, it implementsHttpBody.release(). By calling this method, theFormRouteCompleteris registered as thenext bodyand will be released.- Specified by:
handleFormin interfaceMultiObjectBody- Parameters:
formRouteCompleter- The form route completer that should take over processing
-
release
public final void release()Description copied from interface:HttpBodyRelease this body and any downstream representations. -
next
Description copied from interface:HttpBodyGet the next representation this body was transformed into, if any.
-