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 Details

    • InterceptorChainParameterResolverFactory

      public InterceptorChainParameterResolverFactory()
  • Method Details

    • initialize

      @Deprecated public static void initialize(InterceptorChain interceptorChain)
      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 given action with the given interceptorChain being 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 parameter
      action - The action to invoke
      Returns:
      The response from the invocation of given action
      Throws:
      Exception - any exception that occurs while invoking given action
    • currentInterceptorChain

      public static InterceptorChain currentInterceptorChain()
      Returns the current interceptor chain registered for injection as a parameter. Will return the instance passed in callWithInterceptorChain(InterceptorChain, Callable). When invoked outside the scope of that method, this will return null.
      Returns:
      the InterceptorChain instance passed in callWithInterceptorChain(InterceptorChain, Callable)
    • resolveParameterValue

      public InterceptorChain resolveParameterValue(Message<?> message)
      Description copied from interface: ParameterResolver
      Resolves the parameter value to use for the given message, or null if no suitable parameter value can be resolved.
      Specified by:
      resolveParameterValue in interface ParameterResolver<InterceptorChain>
      Parameters:
      message - The message to resolve the value from
      Returns:
      the parameter value for the handler
    • matches

      public boolean matches(Message<?> message)
      Description copied from interface: ParameterResolver
      Indicates whether this resolver is capable of providing a value for the given message.
      Specified by:
      matches in interface ParameterResolver<InterceptorChain>
      Parameters:
      message - The message to evaluate
      Returns:
      true if this resolver can provide a value for the message, otherwise false
    • createInstance

      public ParameterResolver<InterceptorChain> createInstance(Executable executable, Parameter[] parameters, int parameterIndex)
      Description copied from interface: ParameterResolverFactory
      If available, creates a ParameterResolver instance that can provide a parameter of type parameterType for a given message.

      If the ParameterResolverFactory cannot provide a suitable ParameterResolver, returns null.

      Specified by:
      createInstance in interface ParameterResolverFactory
      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 a ParameterResolver for
      Returns:
      a suitable ParameterResolver, or null if none is found