Class RestOpInvoker

java.lang.Object
org.apache.juneau.rest.server.stats.MethodInvoker
org.apache.juneau.rest.server.RestOpInvoker

public class RestOpInvoker extends MethodInvoker
A specialized invoker for methods that are called during a servlet request.
See Also:
  • Constructor Details

  • Method Details

    • invoke

      public void invoke(RestOpSession opSession) throws Exception
      Invokes this method from the specified RestOpSession.
      Parameters:
      opSession - The REST call. Must not be null.
      Throws:
      Exception - If an error occurred during either parameter resolution or method invocation.
    • invokeOp

      public void invokeOp(RestOpSession opSession) throws Exception
      Invokes this method as the main @RestOp handler from the specified RestOpSession, firing per-request observability hooks (MetricsRecorder and TracerHook) around the underlying invocation.

      Called by RestOpSession.run() for the @RestOp-annotated handler method. Pre / post call methods (those invoked via RestContext.preCall(RestOpSession) / RestContext.postCall(RestOpSession)) continue to use invoke(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.

      CompletableFuture returns

      When the handler returns a CompletionStage, the observability close is deferred to the future's whenComplete callback so metrics and traces capture the actual completion time and outcome — not the synchronous "future returned" moment.

      Parameters:
      opSession - The REST call. Must not be null.
      Throws:
      Exception - If an error occurred during either parameter resolution or method invocation.