Class InterceptorChainParameterResolverFactory
java.lang.Object
org.axonframework.messaging.core.interception.annotation.InterceptorChainParameterResolverFactory
- All Implemented Interfaces:
ParameterResolver<MessageHandlerInterceptorChain<?>>,ParameterResolverFactory
public class InterceptorChainParameterResolverFactory
extends Object
implements ParameterResolverFactory, ParameterResolver<MessageHandlerInterceptorChain<?>>
Parameter resolver factory that adds support for resolving current
MessageHandlerInterceptorChain. This can
function only if there is a ProcessingContext.- Since:
- 3.3.0
- Author:
- Milan Savic
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <M extends Message>
MessageStream<?> callWithInterceptorChain(ProcessingContext processingContext, MessageHandlerInterceptorChain<M> interceptorChain, Function<ProcessingContext, MessageStream<?>> action) Invoke the givenactionwith the giveninterceptorChainbeing available for parameter injection.static <M extends Message>
ProcessingContextcontextWithInterceptorChain(ProcessingContext processingContext, MessageHandlerInterceptorChain<M> interceptorChain) Deprecated, for removal: This API element is subject to removal in a future version.@Nullable ParameterResolver<MessageHandlerInterceptorChain<?>> createInstance(Executable executable, Parameter[] parameters, int parameterIndex) If available, creates aParameterResolverinstance that can provide a parameter of typeparameterTypefor a given message.static <M extends Message>
@Nullable MessageHandlerInterceptorChain<M> currentInterceptorChain(ProcessingContext processingContext) Returns the current interceptor chain registered in the givenprocessingContext, ornullif none is present.booleanmatches(ProcessingContext context) Indicates whether this resolver is capable of providing a value for the givencontext.resolveParameterValue(ProcessingContext context) Asynchronously resolves the parameter value from thecontext.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.messaging.core.annotation.ParameterResolver
supportedPayloadType
-
Constructor Details
-
InterceptorChainParameterResolverFactory
public InterceptorChainParameterResolverFactory()
-
-
Method Details
-
callWithInterceptorChain
public static <M extends Message> MessageStream<?> callWithInterceptorChain(ProcessingContext processingContext, MessageHandlerInterceptorChain<M> interceptorChain, Function<ProcessingContext, MessageStream<?>> action) Invoke the givenactionwith the giveninterceptorChainbeing available for parameter injection. Because this parameter is not bound to a message, it is important to invoke handlers using this method.- Type Parameters:
M- the message type- Parameters:
processingContext- theProcessingContextto useinterceptorChain- the InterceptorChain to consider for injection as parameteraction- the action to invoke- Returns:
- the response from the invocation of given
action
-
contextWithInterceptorChain
@Deprecated(since="5.2.0", forRemoval=true) public static <M extends Message> ProcessingContext contextWithInterceptorChain(ProcessingContext processingContext, MessageHandlerInterceptorChain<M> interceptorChain) Deprecated, for removal: This API element is subject to removal in a future version.Creates a newProcessingContextthat carries the giveninterceptorChainas a resource, making it available for parameter injection viacurrentInterceptorChain(ProcessingContext).Use this in synchronous code paths where the chain must be injected without going through the async
callWithInterceptorChain(ProcessingContext, MessageHandlerInterceptorChain, java.util.function.Function)wrapper.- Type Parameters:
M- the message type- Parameters:
processingContext- the base context to extendinterceptorChain- the interceptor chain to register- Returns:
- a new context with the chain registered as a resource
-
currentInterceptorChain
public static <M extends Message> @Nullable MessageHandlerInterceptorChain<M> currentInterceptorChain(ProcessingContext processingContext) Returns the current interceptor chain registered in the givenprocessingContext, ornullif none is present. The chain is stored viacallWithInterceptorChain(ProcessingContext, MessageHandlerInterceptorChain, Function)and is available for the duration of that call.- Type Parameters:
M- the message type- Parameters:
processingContext- the processing context to retrieve the interceptor chain from- Returns:
- the interceptor chain registered in the context, or
nullif not present
-
resolveParameterValue
public CompletableFuture<MessageHandlerInterceptorChain<?>> resolveParameterValue(ProcessingContext context) Description copied from interface:ParameterResolverAsynchronously resolves the parameter value from thecontext.- Specified by:
resolveParameterValuein interfaceParameterResolver<MessageHandlerInterceptorChain<?>>- Parameters:
context- The current processing context.- Returns:
- A
CompletableFuturethat will complete with the parameter value, or completes withnull.
-
matches
Description copied from interface:ParameterResolverIndicates whether this resolver is capable of providing a value for the givencontext.- Specified by:
matchesin interfaceParameterResolver<MessageHandlerInterceptorChain<?>>- Parameters:
context- The current processing context.- Returns:
- Returns
trueif this resolver can provide a value for the message, otherwisefalse.
-
createInstance
public @Nullable ParameterResolver<MessageHandlerInterceptorChain<?>> 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.
-
callWithInterceptorChain(ProcessingContext, MessageHandlerInterceptorChain, Function)instead.