Class InterceptorChainParameterResolverFactory
java.lang.Object
org.axonframework.messaging.core.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 <R> RcallWithInterceptorChainSync(MessageHandlerInterceptorChain<?> interceptorChain, Callable<R> action) Invoke the givenactionwith the giveninterceptorChainbeing available for parameter injection.createInstance(Executable executable, Parameter[] parameters, int parameterIndex) If available, creates aParameterResolverinstance that can provide a parameter of typeparameterTypefor a given message.static MessageHandlerInterceptorChain<?> Returns the current interceptor chain registered for injection as a parameter.static <M extends Message>
MessageHandlerInterceptorChain<M> currentInterceptorChain(ProcessingContext processingContext) 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
-
callWithInterceptorChainSync
public static <R> R callWithInterceptorChainSync(MessageHandlerInterceptorChain<?> interceptorChain, Callable<R> action) throws Exception 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:
R- The type of response expected from the invocation- Parameters:
interceptorChain- The InterceptorChain to consider for injection as parameteraction- The action to invoke- Returns:
- The response from the invocation of given
action - Throws:
Exception- any exception that occurs while invoking givenaction
-
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.- Parameters:
interceptorChain- The InterceptorChain to consider for injection as parameteraction- The action to invoke- Returns:
- The response from the invocation of given
action
-
currentInterceptorChain
Returns the current interceptor chain registered for injection as a parameter. Will return the instance passed incallWithInterceptorChainSync(MessageHandlerInterceptorChain, Callable). When invoked outside the scope of that method, this will returnnull.- Returns:
- the InterceptorChain instance passed in
callWithInterceptorChainSync(MessageHandlerInterceptorChain, Callable)
-
currentInterceptorChain
public static <M extends Message> MessageHandlerInterceptorChain<M> currentInterceptorChain(ProcessingContext processingContext) -
resolveParameterValue
@Nonnull public CompletableFuture<MessageHandlerInterceptorChain<?>> resolveParameterValue(@Nonnull 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
@Nullable public ParameterResolver<MessageHandlerInterceptorChain<?>> 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.
-