Class RestOpInvoker
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRestOpInvoker(Method m, RestOpArg[] opArgs, MethodExecStats stats) Constructor.RestOpInvoker(Method m, RestOpArg[] opArgs, MethodExecStats stats, Supplier<Object> resourceSupplier) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidinvoke(RestOpSession opSession) Invokes this method from the specifiedRestOpSession.voidinvokeOp(RestOpSession opSession) Invokes this method as the main@RestOphandler from the specifiedRestOpSession, firing per-request observability hooks (MetricsRecorderandTracerHook) around the underlying invocation.Methods inherited from class org.apache.juneau.rest.server.stats.MethodInvoker
getDeclaringClass, getFullName, getStats, inner, invoke, invoke
-
Constructor Details
-
RestOpInvoker
Constructor.- Parameters:
m- The method being wrapped.opArgs- The parameter resolvers.stats- The instrumentor.
-
RestOpInvoker
public RestOpInvoker(Method m, RestOpArg[] opArgs, MethodExecStats stats, Supplier<Object> resourceSupplier) Constructor.- Parameters:
m- The method being wrapped.opArgs- The parameter resolvers.stats- The instrumentor.resourceSupplier- Optional resource supplier. Whennull , falls back toRestSession.getResource().
-
-
Method Details
-
invoke
Invokes this method from the specifiedRestOpSession.- Parameters:
opSession- The REST call. Must not benull .- Throws:
Exception- If an error occurred during either parameter resolution or method invocation.
-
invokeOp
Invokes this method as the main@RestOphandler from the specifiedRestOpSession, firing per-request observability hooks (MetricsRecorderandTracerHook) around the underlying invocation.Called by
RestOpSession.run()for the@RestOp-annotated handler method. Pre / post call methods (those invoked viaRestContext.preCall(RestOpSession)/RestContext.postCall(RestOpSession)) continue to useinvoke(RestOpSession)so the observability boundary stays anchored on the user-facing handler.Virtual-thread dispatch
When the operation opts into virtual threads via
@Rest(virtualThreads=true)or@RestOp(virtualThreads=true)and the runtime is Java 21+, the entire body of this method (parameter resolution, observability scope opening, handler invocation, observability close) is submitted to the resource's virtual-thread executor and the request thread blocks on completion. That keeps observability scoping correct (open and close run on the same thread) while letting blocking I/O inside the handler park a virtual thread instead of the carrier.CompletableFuturereturnsWhen the handler returns a
CompletionStage, the observability close is deferred to the future'swhenCompletecallback so metrics and traces capture the actual completion time and outcome — not the synchronous "future returned" moment.- Parameters:
opSession- The REST call. Must not benull .- Throws:
Exception- If an error occurred during either parameter resolution or method invocation.
-