Annotation Interface HandleMessage
MessageType
.
This annotation is not applied to handler methods directly, but is used as a meta-annotation on other handler
annotations such as HandleEvent
, HandleCommand
, or HandleQuery
. It defines the message
semantics and optional constraints on the payload types that can be handled.
The value()
element specifies the MessageType
this handler annotation corresponds to (e.g., EVENT,
COMMAND, QUERY).
The allowedClasses()
element can be used to restrict which payload types are valid for handler methods
annotated with the derived annotation. This is particularly useful when a single handler method is intended to handle
multiple related message types (e.g., a common base class or interface).
- See Also:
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionThe type of message this handler annotation is intended to process. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<?>[]
Optional list of payload types that are allowed for handler methods using this annotation.
-
Element Details
-
value
MessageType valueThe type of message this handler annotation is intended to process. This determines how the framework routes and dispatches the message to handlers.- Returns:
- the message type (e.g., EVENT, COMMAND, QUERY)
-
allowedClasses
Class<?>[] allowedClassesOptional list of payload types that are allowed for handler methods using this annotation.If empty (default), any payload type is accepted. If one or more classes are specified, the handler method will only be considered for messages whose payload type is assignable to one of the specified classes.
Note that handler methods may still filter the payload type of messages they handle using their method parameters. This allows fine-grained control even when
allowedClasses
is left broad or empty.- Returns:
- array of permitted payload classes for the handler. If empty, any payload type is accepted.
- Default:
{}
-