Class AnnotationMessageTypeResolver
java.lang.Object
org.axonframework.messaging.core.annotation.AnnotationMessageTypeResolver
- All Implemented Interfaces:
MessageTypeResolver
A
MessageTypeResolver implementation looking for configurable annotations on the Class this resolver
is invoked for.
This resolver can use unique annotations per attribute. The attributes searched for are the namespace, name, and
version, reflecting the QualifiedName.namespace(), QualifiedName.localName(), and
MessageType.version(). The default annotation for the name and version is the Message annotation,
from which the name and Message.version() attributes will be used respectively. The
namespace attribute is determined by the Namespace annotation instead. The Message annotation is
meta-annotated with the namespace annotation as a fallback.
Allows for defining a fallback MessageTypeResolver, for when the defined annotations are not present.
- Since:
- 5.0.0
- Author:
- Steven van Beelen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAn annotation specification unique to theAnnotationMessageTypeResolver. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a defaultAnnotationMessageTypeResolver, using theClassBasedMessageTypeResolveras the fallback when there is noMessageannotation present on the givenpayloadTypefor resolving the name and version specifically.AnnotationMessageTypeResolver(@Nullable MessageTypeResolver fallback) Constructs a defaultAnnotationMessageTypeResolver, using the givenfallbackwhen there is noMessagepresent on the givenpayloadTypefor resolving the name and version specifically.AnnotationMessageTypeResolver(@Nullable MessageTypeResolver fallback, AnnotationMessageTypeResolver.AnnotationSpecification specification) Constructs a defaultAnnotationMessageTypeResolver, using the givenfallbackwhen the definedAnnotationMessageTypeResolver.AnnotationSpecification.nameAnnotation()andAnnotationMessageTypeResolver.AnnotationSpecification.versionAnnotation()in the givenspecificationare not present on the givenpayloadTypewhen resolving theMessageType. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.messaging.core.MessageTypeResolver
resolve, resolveOrThrow, resolveOrThrow
-
Constructor Details
-
AnnotationMessageTypeResolver
public AnnotationMessageTypeResolver()Constructs a defaultAnnotationMessageTypeResolver, using theClassBasedMessageTypeResolveras the fallback when there is noMessageannotation present on the givenpayloadTypefor resolving the name and version specifically. -
AnnotationMessageTypeResolver
Constructs a defaultAnnotationMessageTypeResolver, using the givenfallbackwhen there is noMessagepresent on the givenpayloadTypefor resolving the name and version specifically.- Parameters:
fallback- the message type resolver to use as fall back when theMessageannotation is not present on the givenpayloadTypefor resolving the name and version specifically
-
AnnotationMessageTypeResolver
public AnnotationMessageTypeResolver(@Nullable MessageTypeResolver fallback, AnnotationMessageTypeResolver.AnnotationSpecification specification) Constructs a defaultAnnotationMessageTypeResolver, using the givenfallbackwhen the definedAnnotationMessageTypeResolver.AnnotationSpecification.nameAnnotation()andAnnotationMessageTypeResolver.AnnotationSpecification.versionAnnotation()in the givenspecificationare not present on the givenpayloadTypewhen resolving theMessageType.- Parameters:
fallback- the message type resolver to use as fall back when theAnnotationMessageTypeResolver.AnnotationSpecification.nameAnnotation()andAnnotationMessageTypeResolver.AnnotationSpecification.versionAnnotation()as defined in the givenspecificationare not present on the givenpayloadTypewhen resolving theMessageTypespecification- the specification that determines what annotation to look for on the givenpayloadTypewhen resolving theMessageType
-
-
Method Details
-
resolve
Description copied from interface:MessageTypeResolverResolves atypefor the givenpayloadType.This method returns an
Optionalthat will be empty if thetypecould not be resolved.- Specified by:
resolvein interfaceMessageTypeResolver- Parameters:
payloadType- Thetypeof theMessage payloadto resolve atypefor.- Returns:
- An
Optionalcontaining thetypefor the givenpayloadType, or empty if the type could not be resolved.
-