org.axonframework.commandhandling.annotation
Class AnnotationCommandTargetResolver

java.lang.Object
  extended by org.axonframework.commandhandling.annotation.AnnotationCommandTargetResolver
All Implemented Interfaces:
CommandTargetResolver

public class AnnotationCommandTargetResolver
extends Object
implements 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 used 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

Constructor Summary
AnnotationCommandTargetResolver()
           
 
Method Summary
 VersionedAggregateIdentifier resolveTarget(CommandMessage<?> command)
          Returns the Aggregate Identifier and optionally the expected version of the aggregate on which the given command should be executed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationCommandTargetResolver

public AnnotationCommandTargetResolver()
Method Detail

resolveTarget

public VersionedAggregateIdentifier resolveTarget(CommandMessage<?> command)
Description copied from interface: CommandTargetResolver
Returns the Aggregate Identifier and optionally the expected version of the aggregate on which the given command should be executed. The version may be null if no specific version is required.

Specified by:
resolveTarget in interface CommandTargetResolver
Parameters:
command - The command from which to extract the identifier and version
Returns:
a VersionedAggregateIdentifier instance reflecting the aggregate to execute the command on


Copyright © 2010-2016. All Rights Reserved.