Class ResultParameterResolverFactory
java.lang.Object
org.axonframework.messaging.core.interception.annotation.ResultParameterResolverFactory
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectcallWithResult(Object result, Callable<?> action) Calls the givenaction(typically a handler invocation) such that the givenresultis available for injection as parameterstatic <R> RcallWithResult(Object result, ProcessingContext processingContext, Function<ProcessingContext, R> action) createInstance(Executable executable, Parameter[] parameters, int parameterIndex) If available, creates aParameterResolverinstance that can provide a parameter of typeparameterTypefor a given message.static <T> TignoringResultParameters(ProcessingContext processingContext, Function<ProcessingContext, T> action) Performs the givenactionignoring any parameters expecting a result type.
-
Constructor Details
-
ResultParameterResolverFactory
public ResultParameterResolverFactory()
-
-
Method Details
-
callWithResult
public static <R> R callWithResult(Object result, ProcessingContext processingContext, Function<ProcessingContext, R> action) -
callWithResult
Calls the givenaction(typically a handler invocation) such that the givenresultis available for injection as parameter- Parameters:
result- The result to make available for parameter injectionaction- The action to take- Returns:
- the result of the action
- Throws:
Exception- any exception thrown while executing theaction
-
ignoringResultParameters
public static <T> T ignoringResultParameters(ProcessingContext processingContext, Function<ProcessingContext, T> action) Performs the givenactionignoring 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:ParameterResolverFactoryIf available, creates aParameterResolverinstance that can provide a parameter of typeparameterTypefor a given message.If the
ParameterResolverFactorycannot provide a suitableParameterResolver, returnsnull.- Specified by:
createInstancein interfaceParameterResolverFactory- 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 aParameterResolverfor.- Returns:
- A suitable
ParameterResolver, ornullif none is found.
-