Class ResultParameterResolverFactory

java.lang.Object
org.axonframework.messaging.core.interception.annotation.ResultParameterResolverFactory
All Implemented Interfaces:
ParameterResolverFactory

public class ResultParameterResolverFactory extends Object implements ParameterResolverFactory
ParameterResolverFactory that provides support for Parameters where the result of Handler execution is expected to be injected. This is only possible in interceptor handlers that need to act on the result of downstream interceptors or the regular handler.

The @ResultHandler Meta-Annotation needs to be placed on handlers that support interacting with the result type in its parameters.

Since:
4.4.0
Author:
Allard Buijze
  • Constructor Details

    • ResultParameterResolverFactory

      public ResultParameterResolverFactory()
  • Method Details

    • callWithResult

      public static <R> R callWithResult(Object result, ProcessingContext processingContext, Function<ProcessingContext,R> action)
    • callWithResult

      public static Object callWithResult(Object result, Callable<?> action) throws Exception
      Calls the given action (typically a handler invocation) such that the given result is available for injection as parameter
      Parameters:
      result - The result to make available for parameter injection
      action - The action to take
      Returns:
      the result of the action
      Throws:
      Exception - any exception thrown while executing the action
    • ignoringResultParameters

      public static <T> T ignoringResultParameters(ProcessingContext processingContext, Function<ProcessingContext,T> action)
      Performs the given action ignoring any parameters expecting a result type. This is typically used to detect whether a handler is suitable for invocation prior to the result value being available.
      Type Parameters:
      T - The type of result expected from the action
      Parameters:
      action - The action to perform
      Returns:
      the result returned by the given action
    • createInstance

      @Nullable public ParameterResolver<Object> createInstance(@Nonnull Executable executable, @Nonnull Parameter[] parameters, int parameterIndex)
      Description copied from interface: ParameterResolverFactory
      If available, creates a ParameterResolver instance that can provide a parameter of type parameterType for a given message.

      If the ParameterResolverFactory cannot provide a suitable ParameterResolver, returns null.

      Specified by:
      createInstance in interface ParameterResolverFactory
      Parameters:
      executable - The executable (constructor or method) to inspect.
      parameters - The parameters on the executable to inspect.
      parameterIndex - The index of the parameter to return a ParameterResolver for.
      Returns:
      A suitable ParameterResolver, or null if none is found.