Class AnnotationCommandTargetResolver
java.lang.Object
org.axonframework.modelling.command.AnnotationCommandTargetResolver
- All Implemented Interfaces:
CommandTargetResolver
CommandTargetResolver that uses annotations on the command to identify the methods that provide the Aggregate
Identifier of the targeted Aggregate and optionally the expected version of the aggregate.
This implementation expects at least one method (without parameters) or field in the command to be annotated with
TargetAggregateIdentifier. If on a method, the result of the invocation of that method will use as Aggregate
Identifier. If on a field, the value held in that field is used.
Similarly, the expected aggregate version may be provided by annotating a method (without parameters) or field with
TargetAggregateVersion. The return value of the method or value held in the field is used as the expected
version. Note that the method must return a Long value, or a value that may be parsed as a Long.- Since:
- 1.2
- Author:
- Allard Buijze
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder class to instantiate aAnnotationCommandTargetResolver. -
Constructor Summary
ConstructorsModifierConstructorDescriptionDeprecated.protectedInstantiate aAnnotationCommandTargetResolverbased on the fields contained in theAnnotationCommandTargetResolver.Builder. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Instantiate a Builder to be able to create aAnnotationCommandTargetResolver.resolveTarget(CommandMessage<?> command) Returns the Aggregate Identifier and optionally the expected version of the aggregate on which the givencommandshould be executed.toString()
-
Constructor Details
-
AnnotationCommandTargetResolver
Deprecated.Please use thebuilder(). -
AnnotationCommandTargetResolver
Instantiate aAnnotationCommandTargetResolverbased on the fields contained in theAnnotationCommandTargetResolver.Builder.- Parameters:
builder- theAnnotationCommandTargetResolver.Builderused to instantiate aAnnotationCommandTargetResolverinstance
-
-
Method Details
-
builder
Instantiate a Builder to be able to create aAnnotationCommandTargetResolver.The TargetAggregateIdentifierAnnotation is defaulted to
TargetAggregateIdentifier, TargetAggregateVersionAnnotation toTargetAggregateVersion.- Returns:
- a Builder to be able to create a
AnnotationCommandTargetResolver
-
resolveTarget
Returns the Aggregate Identifier and optionally the expected version of the aggregate on which the givencommandshould be executed.The version may be
nullif no specific version is required. Furthermore, the returnedVersionedAggregateIdentifiermay be null entirely when the givencommandis targeted towards aCreationPolicyannotated command handler that (optionally) constructs a new aggregate instance.- Specified by:
resolveTargetin interfaceCommandTargetResolver- Parameters:
command- The command from which to extract the identifier and version.- Returns:
- A
VersionedAggregateIdentifierinstance reflecting the aggregate to execute the command on, ornullwhen thecommandis targeted towards aCreationPolicyannotated command handler that constructs a new aggregate instance. - See Also:
-
toString
-
builder().