Class InterceptorChainParameterResolverFactory
java.lang.Object
org.axonframework.messaging.annotation.InterceptorChainParameterResolverFactory
- All Implemented Interfaces:
ParameterResolver<InterceptorChain>,ParameterResolverFactory
public class InterceptorChainParameterResolverFactory
extends Object
implements ParameterResolverFactory, ParameterResolver<InterceptorChain>
Parameter resolver factory that adds support for resolving current
InterceptorChain. InterceptorChain
can be initialized using static method initialize(InterceptorChain).
This can function only if there is an active UnitOfWork.- Since:
- 3.3
- Author:
- Milan Savic
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <R> RcallWithInterceptorChain(InterceptorChain interceptorChain, Callable<R> action) Invoke the givenactionwith the giveninterceptorChainbeing available for parameter injection.createInstance(Executable executable, Parameter[] parameters, int parameterIndex) If available, creates a ParameterResolver instance that can provide a parameter of typeparameterTypefor a given message.static InterceptorChainReturns the current interceptor chain registered for injection as a parameter.static voidinitialize(InterceptorChain interceptorChain) Deprecated.booleanIndicates whether this resolver is capable of providing a value for the givenmessage.resolveParameterValue(Message<?> message) Resolves the parameter value to use for the givenmessage, ornullif no suitable parameter value can be resolved.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.messaging.annotation.ParameterResolver
supportedPayloadType
-
Constructor Details
-
InterceptorChainParameterResolverFactory
public InterceptorChainParameterResolverFactory()
-
-
Method Details
-
initialize
Deprecated.Initializes current unit of work with interceptor chain.- Parameters:
interceptorChain- the interceptor chain
-
callWithInterceptorChain
public static <R> R callWithInterceptorChain(InterceptorChain 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
-
currentInterceptorChain
Returns the current interceptor chain registered for injection as a parameter. Will return the instance passed incallWithInterceptorChain(InterceptorChain, Callable). When invoked outside the scope of that method, this will returnnull.- Returns:
- the InterceptorChain instance passed in
callWithInterceptorChain(InterceptorChain, Callable)
-
resolveParameterValue
Description copied from interface:ParameterResolverResolves the parameter value to use for the givenmessage, ornullif no suitable parameter value can be resolved.- Specified by:
resolveParameterValuein interfaceParameterResolver<InterceptorChain>- Parameters:
message- The message to resolve the value from- Returns:
- the parameter value for the handler
-
matches
Description copied from interface:ParameterResolverIndicates whether this resolver is capable of providing a value for the givenmessage.- Specified by:
matchesin interfaceParameterResolver<InterceptorChain>- Parameters:
message- The message to evaluate- Returns:
trueif this resolver can provide a value for the message, otherwisefalse
-
createInstance
public ParameterResolver<InterceptorChain> createInstance(Executable executable, Parameter[] parameters, int parameterIndex) Description copied from interface:ParameterResolverFactoryIf available, creates a ParameterResolver instance that can provide a parameter of typeparameterTypefor a given message.If the ParameterResolverFactory cannot provide a suitable ParameterResolver, returns
null.- Specified by:
createInstancein interfaceParameterResolverFactory- Parameters:
executable- The executable (constructor or method) to inspectparameters- The parameters on the executable to inspectparameterIndex- The index of the parameter to return a ParameterResolver for- Returns:
- a suitable ParameterResolver, or
nullif none is found
-
callWithInterceptorChain(InterceptorChain, Callable)