Class MultiHandlerDefinition

java.lang.Object
org.axonframework.messaging.core.annotation.MultiHandlerDefinition
All Implemented Interfaces:
HandlerDefinition

public class MultiHandlerDefinition extends Object implements HandlerDefinition
HandlerDefinition instance that delegates to multiple other instances, in the order provided. Also, it wraps the delegate with HandlerEnhancerDefinition.
Since:
3.3.0
Author:
Tyler Thrailkill, Milan Savic
  • Constructor Details

    • MultiHandlerDefinition

      public MultiHandlerDefinition(HandlerDefinition... delegates)
      Initializes an instance that delegates to the given delegates, in the order provided. Changes in the given array are not reflected in the created instance.
      Parameters:
      delegates - The handlerDefinitions providing the parameter values to use
    • MultiHandlerDefinition

      public MultiHandlerDefinition(List<HandlerDefinition> delegates)
      Initializes an instance that delegates to the given delegates, in the order provided. Changes in the given list are not reflected in the created instance.
      Parameters:
      delegates - The handlerDefinitions providing the parameter values to use
    • MultiHandlerDefinition

      public MultiHandlerDefinition(List<HandlerDefinition> delegates, HandlerEnhancerDefinition handlerEnhancerDefinition)
      Initializes an instance that delegates to the given delegates, in the order provided. Changes in the given List are not reflected in the created instance.
      Parameters:
      delegates - The list of handlerDefinitions providing the parameter values to use
      handlerEnhancerDefinition - The enhancer used to wrap the delegates
  • Method Details

    • ordered

      public static MultiHandlerDefinition ordered(HandlerDefinition... delegates)
      Creates a MultiHandlerDefinition instance with the given delegates, which are automatically ordered based on the @Priority annotation on their respective classes. Classes with the same Priority are kept in the order as provided in the delegates. As an enhancer, ClasspathHandlerEnhancerDefinition is used.

      If one of the delegates is a MultiHandlerDefinition itself, that factory's delegates are 'mixed' with the given delegates, based on their respective order.

      Parameters:
      delegates - The delegates to include in the factory
      Returns:
      an instance delegating to the given delegates
    • ordered

      public static MultiHandlerDefinition ordered(HandlerEnhancerDefinition handlerEnhancerDefinition, HandlerDefinition... delegates)
      Creates a MultiHandlerDefinition instance with the given delegates, which are automatically ordered based on the @Priority annotation on their respective classes. Classes with the same Priority are kept in the order as provided in the delegates. As an enhancer, provided one is used.

      If one of the delegates is a MultiHandlerDefinition itself, that factory's delegates are 'mixed' with the given delegates, based on their respective order.

      Parameters:
      handlerEnhancerDefinition - The enhancer used to wrap the delegates
      delegates - The delegates to include in the factory
      Returns:
      an instance delegating to the given delegates
    • ordered

      public static MultiHandlerDefinition ordered(List<HandlerDefinition> delegates)
      Creates a MultiHandlerDefinition instance with the given delegates, which are automatically ordered based on the @Priority annotation on their respective classes. Classes with the same Priority are kept in the order as provided in the delegates. As an enhancer, ClasspathHandlerEnhancerDefinition is used.

      If one of the delegates is a MultiHandlerDefinition itself, that factory's delegates are 'mixed' with the given delegates, based on their respective order.

      Parameters:
      delegates - The delegates to include in the factory
      Returns:
      an instance delegating to the given delegates
    • ordered

      public static MultiHandlerDefinition ordered(List<HandlerDefinition> delegates, HandlerEnhancerDefinition handlerEnhancerDefinition)
      Creates a MultiHandlerDefinition instance with the given delegates, which are automatically ordered based on the @Priority annotation on their respective classes. Classes with the same Priority are kept in the order as provided in the delegates. As an enhancer, provided one is used.

      If one of the delegates is a MultiHandlerDefinition itself, that factory's delegates are 'mixed' with the given delegates, based on their respective order.

      Parameters:
      delegates - The delegates to include in the factory
      handlerEnhancerDefinition - The enhancer used to wrap the delegates
      Returns:
      an instance delegating to the given delegates
    • getDelegates

      public List<HandlerDefinition> getDelegates()
      Returns the delegates of this instance, in the order they are evaluated to resolve parameters.
      Returns:
      the delegates of this instance, in the order they are evaluated to resolve parameters
    • getHandlerEnhancerDefinition

      public HandlerEnhancerDefinition getHandlerEnhancerDefinition()
      Returns handler enhancer definition used to wrap handlers.
      Returns:
      handler enhancer definition
    • createHandler

      public <T> Optional<MessageHandlingMember<T>> createHandler(@Nonnull Class<T> declaringType, @Nonnull Method method, @Nonnull ParameterResolverFactory parameterResolverFactory, @Nonnull Function<Object,MessageStream<?>> messageStreamResolver)
      Description copied from interface: HandlerDefinition
      Create a MessageHandlingMember for the given method method. Use the given parameterResolverFactory to resolve the method's parameters.
      Specified by:
      createHandler in interface HandlerDefinition
      Type Parameters:
      T - The type of the declaring object
      Parameters:
      declaringType - The type of object declaring the given method
      method - The method to inspect
      parameterResolverFactory - Factory for a ParameterResolver of the method
      messageStreamResolver - The lambda resolving a MessageStream out of the result from MessageHandlingMember.handle(Message, ProcessingContext, Object).
      Returns:
      An optional containing the handler if the method is suitable, or an empty Nullable otherwise.