Class ChildForwardingCommandMessageHandlingMember<P,C>

java.lang.Object
org.axonframework.modelling.command.inspection.ChildForwardingCommandMessageHandlingMember<P,C>
Type Parameters:
P - the parent entity type
C - the child entity type
All Implemented Interfaces:
org.axonframework.commandhandling.CommandMessageHandlingMember<P>, org.axonframework.messaging.annotation.MessageHandlingMember<P>, ForwardingCommandMessageHandlingMember<P>

public class ChildForwardingCommandMessageHandlingMember<P,C> extends Object implements ForwardingCommandMessageHandlingMember<P>
Implementation of a CommandMessageHandlingMember that forwards commands to a child entity.
Since:
3.0
Author:
Allard Buijze
  • Constructor Details

    • ChildForwardingCommandMessageHandlingMember

      public ChildForwardingCommandMessageHandlingMember(List<org.axonframework.messaging.annotation.MessageHandlingMember<? super C>> childHandlerInterceptors, org.axonframework.messaging.annotation.MessageHandlingMember<? super C> childHandler, BiFunction<org.axonframework.commandhandling.CommandMessage<?>,P,C> childEntityResolver)
      Initializes a ChildForwardingCommandMessageHandlingMember that routes commands to a compatible child entity. Child entities are resolved using the given childEntityResolver. If an entity is found the command will be handled using the given childHandler.
      Parameters:
      childHandlerInterceptors - interceptors for childHandler
      childHandler - handler of the command once a suitable entity is found
      childEntityResolver - resolver of child entities for a given command
  • Method Details

    • commandName

      public String commandName()
      Specified by:
      commandName in interface org.axonframework.commandhandling.CommandMessageHandlingMember<P>
    • routingKey

      public String routingKey()
      Specified by:
      routingKey in interface org.axonframework.commandhandling.CommandMessageHandlingMember<P>
    • isFactoryHandler

      public boolean isFactoryHandler()
      Specified by:
      isFactoryHandler in interface org.axonframework.commandhandling.CommandMessageHandlingMember<P>
    • payloadType

      public Class<?> payloadType()
      Specified by:
      payloadType in interface org.axonframework.messaging.annotation.MessageHandlingMember<P>
    • priority

      public int priority()
      Specified by:
      priority in interface org.axonframework.messaging.annotation.MessageHandlingMember<P>
    • canForward

      public boolean canForward(org.axonframework.commandhandling.CommandMessage<?> message, P target)
      Description copied from interface: ForwardingCommandMessageHandlingMember
      Check if this handler is in a state where it can currently accept the command.
      Specified by:
      canForward in interface ForwardingCommandMessageHandlingMember<P>
      Parameters:
      message - The message that is to be forwarded
      target - The target to forward the command message
      Returns:
      true if this handler can forward command to target entity, false otherwise.
    • canHandle

      public boolean canHandle(@Nonnull org.axonframework.messaging.Message<?> message)
      Specified by:
      canHandle in interface org.axonframework.messaging.annotation.MessageHandlingMember<P>
    • canHandleMessageType

      public boolean canHandleMessageType(@Nonnull Class<? extends org.axonframework.messaging.Message> messageType)
      Specified by:
      canHandleMessageType in interface org.axonframework.messaging.annotation.MessageHandlingMember<P>
    • handle

      public Object handle(@Nonnull org.axonframework.messaging.Message<?> message, @Nullable P target) throws Exception
      Specified by:
      handle in interface org.axonframework.messaging.annotation.MessageHandlingMember<P>
      Throws:
      Exception
    • unwrap

      public <HT> Optional<HT> unwrap(Class<HT> handlerType)
      Specified by:
      unwrap in interface org.axonframework.messaging.annotation.MessageHandlingMember<P>
    • hasAnnotation

      public boolean hasAnnotation(Class<? extends Annotation> annotationType)
      Specified by:
      hasAnnotation in interface org.axonframework.messaging.annotation.MessageHandlingMember<P>
    • annotationAttributes

      public Optional<Map<String,Object>> annotationAttributes(Class<? extends Annotation> annotationType)
      Specified by:
      annotationAttributes in interface org.axonframework.messaging.annotation.MessageHandlingMember<P>
    • attribute

      public <R> Optional<R> attribute(String attributeKey)
      Specified by:
      attribute in interface org.axonframework.messaging.annotation.MessageHandlingMember<P>