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 <R> RcallWithResult(Object result, ProcessingContext processingContext, Function<ProcessingContext, R> action) Performs the givenactionwhile making the givenresultavailable for injection into handler parameters annotated withResultHandler.@Nullable ParameterResolver<Object> 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.static ProcessingContextwithResult(Object result, ProcessingContext context) Returns aProcessingContextwith the givenresultavailable for injection viaResultHandler-annotated parameters.
-
Constructor Details
-
ResultParameterResolverFactory
public ResultParameterResolverFactory()
-
-
Method Details
-
callWithResult
public static <R> R callWithResult(Object result, ProcessingContext processingContext, Function<ProcessingContext, R> action) Performs the givenactionwhile making the givenresultavailable for injection into handler parameters annotated withResultHandler.- Type Parameters:
R- the type of result expected from the action- Parameters:
result- the result value to make available for parameter injectionprocessingContext- the processing context to use when performing the actionaction- the action to perform- Returns:
- the result returned by the given action
-
withResult
Returns aProcessingContextwith the givenresultavailable for injection viaResultHandler-annotated parameters. Use this when the caller needs to perform multiple operations (e.g.,canHandlefollowed byhandleSync) with the same wrapped context.- Parameters:
result- the result value to expose for parameter injectioncontext- the base processing context to wrap- Returns:
- a processing context that exposes
resultto result-typed parameters
-
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:
processingContext- theProcessingContextto useaction- the action to perform- Returns:
- the result returned by the given action
-
createInstance
public @Nullable ParameterResolver<Object> createInstance(Executable executable, 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.
-