Interface AsyncHandler.ReturnType<T>

Type Parameters:
T - the async type of the handler
Enclosing interface:
AsyncHandler

public static interface AsyncHandler.ReturnType<T>
A return type async handler is a service provider for this interface declared in META-INF/services. The async type of a return type async handler is the erasure of the type argument to the AsyncHandler.ReturnType direct superinterface type.

A target method matches a return type async handler when the erasure of the method's return type is identical to the async type of the async handler.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    transform(T original, Runnable completion)
    Called once by Invoker.invoke(), after the target method returns.
  • Method Details

    • transform

      T transform(T original, Runnable completion)
      Called once by Invoker.invoke(), after the target method returns. When the target method throws an exception synchronously, this method is not called.

      Takes the original return value and returns a variant of it, transformed such that completion.run() is called on completion. Note that completion.run() must be called exactly once. The result is returned to the invoker caller instead of the original.

      It is recommended that completion.run() is called before completion is propagated to the caller.

      Parameters:
      original - the original asynchronous return value
      completion - action that must be executed when the asynchronous action completes
      Returns:
      the transformed asynchronous return value