Class ChildForwardingCommandMessageHandlingMember<P,C>
- Type Parameters:
P- the parent entity typeC- the child entity type
- All Implemented Interfaces:
CommandMessageHandlingMember<P>,MessageHandlingMember<P>,ForwardingCommandMessageHandlingMember<P>
CommandMessageHandlingMember that forwards commands to a child entity.- Since:
- 3.0
- Author:
- Allard Buijze
-
Constructor Summary
ConstructorsConstructorDescriptionChildForwardingCommandMessageHandlingMember(List<MessageHandlingMember<? super C>> childHandlerInterceptors, MessageHandlingMember<? super C> childHandler, BiFunction<CommandMessage<?>, P, C> childEntityResolver) Initializes aChildForwardingCommandMessageHandlingMemberthat routes commands to a compatible child entity. -
Method Summary
Modifier and TypeMethodDescriptionannotationAttributes(Class<? extends Annotation> annotationType) Get the attributes of an annotation of givenannotationTypeon the method of the target entity.<R> Optional<R> Retrieve a single attributes for the givenattributeKey.booleancanForward(CommandMessage<?> message, P target) Check if this handler is in a state where it can currently accept the command.booleanChecks if this handler is capable of handling the givenmessage.booleancanHandleMessageType(Class<? extends Message> messageType) Checks if this handlers is capable of handlingMessageimplementations of the givenmessageType.Returns the name of the command that can be handled.Handles the givenmessageby invoking the appropriate method on giventarget.booleanhasAnnotation(Class<? extends Annotation> annotationType) Checks whether the method of the target entity contains the givenannotationType.booleanCheck if this message handler creates a new instance of the entity of typeTto handle this command.Class<?> Returns the payload type of messages that can be processed by this handler.intpriority()Returns a number representing the priority of this handler over other handlers capable of processing the same message.Returns the property of the command that is to be used as routing key towards this command handler instance.<HT> Optional<HT> Returns the wrapped handler object if its type is an instance of the givenhandlerType.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.MessageHandlingMember
canHandleType, declaringClass, signature
-
Constructor Details
-
ChildForwardingCommandMessageHandlingMember
public ChildForwardingCommandMessageHandlingMember(List<MessageHandlingMember<? super C>> childHandlerInterceptors, MessageHandlingMember<? super C> childHandler, BiFunction<CommandMessage<?>, P, C> childEntityResolver) Initializes aChildForwardingCommandMessageHandlingMemberthat routes commands to a compatible child entity. Child entities are resolved using the givenchildEntityResolver. If an entity is found the command will be handled using the givenchildHandler.- Parameters:
childHandlerInterceptors- interceptors forchildHandlerchildHandler- handler of the command once a suitable entity is foundchildEntityResolver- resolver of child entities for a given command
-
-
Method Details
-
commandName
Description copied from interface:CommandMessageHandlingMemberReturns the name of the command that can be handled.- Specified by:
commandNamein interfaceCommandMessageHandlingMember<P>- Returns:
- The name of the command that can be handled
-
routingKey
Description copied from interface:CommandMessageHandlingMemberReturns the property of the command that is to be used as routing key towards this command handler instance. If multiple handlers instances are available, a sending component is responsible to route commands with the same routing key value to the correct instance.- Specified by:
routingKeyin interfaceCommandMessageHandlingMember<P>- Returns:
- The property of the command to use as routing key
-
isFactoryHandler
public boolean isFactoryHandler()Description copied from interface:CommandMessageHandlingMemberCheck if this message handler creates a new instance of the entity of typeTto handle this command.This is for instance the case if the message is handled in the constructor method of the entity.
- Specified by:
isFactoryHandlerin interfaceCommandMessageHandlingMember<P>- Returns:
trueif this handler is also factory for entities,falseotherwise.
-
payloadType
Description copied from interface:MessageHandlingMemberReturns the payload type of messages that can be processed by this handler.- Specified by:
payloadTypein interfaceMessageHandlingMember<P>- Returns:
- The payload type of messages expected by this handler
-
priority
public int priority()Description copied from interface:MessageHandlingMemberReturns a number representing the priority of this handler over other handlers capable of processing the same message.In general, a handler with a higher priority will receive the message before (or instead of) handlers with a lower priority. However, the priority value may not be the only indicator that is used to determine the order of invocation. For instance, a message processor may decide to ignore the priority value if one message handler is a more specific handler of the message than another handler.
- Specified by:
priorityin interfaceMessageHandlingMember<P>- Returns:
- Number indicating the priority of this handler over other handlers
-
canForward
Description copied from interface:ForwardingCommandMessageHandlingMemberCheck if this handler is in a state where it can currently accept the command.- Specified by:
canForwardin interfaceForwardingCommandMessageHandlingMember<P>- Parameters:
message- The message that is to be forwardedtarget- The target to forward the command message- Returns:
trueif this handler can forward command to target entity,falseotherwise.
-
canHandle
Description copied from interface:MessageHandlingMemberChecks if this handler is capable of handling the givenmessage.- Specified by:
canHandlein interfaceMessageHandlingMember<P>- Parameters:
message- The message that is to be handled- Returns:
trueif the handler is capable of handling the message,falseotherwise
-
canHandleMessageType
Description copied from interface:MessageHandlingMemberChecks if this handlers is capable of handlingMessageimplementations of the givenmessageType.It is recommended to suppress the raw type use validation of the
messageTypeparameter when implementing this method, as usage of this method with aMessagegeneric would required reflection or casting otherwise.- Specified by:
canHandleMessageTypein interfaceMessageHandlingMember<P>- Parameters:
messageType- theMessage's type to check if it can be handled by this handler- Returns:
trueif this handler can handle the givenmessageType,falseotherwise
-
handle
Description copied from interface:MessageHandlingMemberHandles the givenmessageby invoking the appropriate method on giventarget. This may result in an exception if the given target is not capable of handling the message or if an exception is thrown during invocation of the method.- Specified by:
handlein interfaceMessageHandlingMember<P>- Parameters:
message- The message to handletarget- The target to handle the message- Returns:
- The message handling result in case the invocation was successful
- Throws:
Exception- when there was a problem that prevented invocation of the method or if an exception was thrown from the invoked method
-
unwrap
Description copied from interface:MessageHandlingMemberReturns the wrapped handler object if its type is an instance of the givenhandlerType. For instance, if this method is invoked withExecutableand the message is handled by a method of the target entity, then this method will return the method handle as aMethod.- Specified by:
unwrapin interfaceMessageHandlingMember<P>- Type Parameters:
HT- The wrapped handler type- Parameters:
handlerType- The expected type of the wrapped handler- Returns:
- An Optional containing the wrapped handler object or an empty Optional if the handler is not an instance of the given handlerType
-
hasAnnotation
Description copied from interface:MessageHandlingMemberChecks whether the method of the target entity contains the givenannotationType.- Specified by:
hasAnnotationin interfaceMessageHandlingMember<P>- Parameters:
annotationType- Annotation to check for on the target method- Returns:
trueif the annotation is present on the target method,falseotherwise
-
annotationAttributes
public Optional<Map<String,Object>> annotationAttributes(Class<? extends Annotation> annotationType) Description copied from interface:MessageHandlingMemberGet the attributes of an annotation of givenannotationTypeon the method of the target entity. If the annotation is present on the target method an Optional is returned containing the properties mapped by their name. If the annotation is not present an empty Optional is returned.- Specified by:
annotationAttributesin interfaceMessageHandlingMember<P>- Parameters:
annotationType- The annotation to check for on the target method- Returns:
- An optional containing a map of the properties of the annotation, or an empty optional if the annotation is missing on the method
-
attribute
Description copied from interface:MessageHandlingMemberRetrieve a single attributes for the givenattributeKey. If thisMessageHandlingMemberdoes not hold a value referencing theattributeKey, anOptional.empty()is returned. Otherwise a non-emptyOptionalcontaining the attribute will be provided.When using the method, consider checking the
HandlerAttributesfor a list of common handler attributes.- Specified by:
attributein interfaceMessageHandlingMember<P>- Parameters:
attributeKey- the key to retrieve an attribute for- Returns:
- a non-empty
Optionalof the attribute referencing the givenattributeKey. Otherwise anOptional.empty()will be returned
-