T - the type of aggregate this handler handles commands forpublic class AggregateAnnotationCommandHandler<T> extends Object implements MessageHandler<CommandMessage<?>>, SupportedCommandNamesAware
CommandHandler
 annotations on an aggregate. Those annotations may appear on methods, in which case a specific aggregate instance
 needs to be targeted by the command, or on the constructor. The latter will create a new Aggregate instance, which
 is then stored in the repository.| Constructor and Description | 
|---|
AggregateAnnotationCommandHandler(Class<T> aggregateType,
                                 Repository<T> repository)
Initializes an AnnotationCommandHandler based on the annotations on given  
aggregateType, using the
 given repository to add and load aggregate instances. | 
AggregateAnnotationCommandHandler(Class<T> aggregateType,
                                 Repository<T> repository,
                                 CommandTargetResolver commandTargetResolver)
Initializes an AnnotationCommandHandler based on the annotations on given  
aggregateType, using the
 given repository to add and load aggregate instances and the default ParameterResolverFactory. | 
AggregateAnnotationCommandHandler(Class<T> aggregateType,
                                 Repository<T> repository,
                                 CommandTargetResolver commandTargetResolver,
                                 ParameterResolverFactory parameterResolverFactory)
Initializes an AnnotationCommandHandler based on the annotations on given  
aggregateType, using the
 given repository to add and load aggregate instances and the given
 parameterResolverFactory. | 
AggregateAnnotationCommandHandler(Repository<T> repository,
                                 CommandTargetResolver commandTargetResolver,
                                 AggregateModel<T> aggregateModel)
Initializes an AnnotationCommandHandler based on the annotations on given  
aggregateType, using the
 given repository to add and load aggregate instances and the given
 parameterResolverFactory. | 
| Modifier and Type | Method and Description | 
|---|---|
Object | 
handle(CommandMessage<?> commandMessage)
Handles the given  
message. | 
protected Object | 
resolveReturnValue(CommandMessage<?> command,
                  Aggregate<T> createdAggregate)
Resolves the value to return when the given  
command has created the given aggregate. | 
Registration | 
subscribe(CommandBus commandBus)
Subscribe this command handler to the given  
commandBus. | 
Set<String> | 
supportedCommandNames()
Returns the set of command names this component supports. 
 | 
public AggregateAnnotationCommandHandler(Class<T> aggregateType, Repository<T> repository)
aggregateType, using the
 given repository to add and load aggregate instances.aggregateType - The type of aggregaterepository - The repository providing access to aggregate instancespublic AggregateAnnotationCommandHandler(Class<T> aggregateType, Repository<T> repository, CommandTargetResolver commandTargetResolver)
aggregateType, using the
 given repository to add and load aggregate instances and the default ParameterResolverFactory.aggregateType - The type of aggregaterepository - The repository providing access to aggregate instancescommandTargetResolver - The target resolution strategypublic AggregateAnnotationCommandHandler(Class<T> aggregateType, Repository<T> repository, CommandTargetResolver commandTargetResolver, ParameterResolverFactory parameterResolverFactory)
aggregateType, using the
 given repository to add and load aggregate instances and the given
 parameterResolverFactory.aggregateType - The type of aggregaterepository - The repository providing access to aggregate instancescommandTargetResolver - The target resolution strategyparameterResolverFactory - The strategy for resolving parameter values for handler methodspublic AggregateAnnotationCommandHandler(Repository<T> repository, CommandTargetResolver commandTargetResolver, AggregateModel<T> aggregateModel)
aggregateType, using the
 given repository to add and load aggregate instances and the given
 parameterResolverFactory.repository - The repository providing access to aggregate instancescommandTargetResolver - The target resolution strategyaggregateModel - The description of the command handling modelpublic Registration subscribe(CommandBus commandBus)
commandBus. The command handler will be subscribed
 for each of the supported commands.commandBus - The command bus instance to subscribe topublic Object handle(CommandMessage<?> commandMessage) throws Exception
MessageHandlermessage.handle in interface MessageHandler<CommandMessage<?>>commandMessage - The message to be processed.Exception - any exception that occurs during message handlingprotected Object resolveReturnValue(CommandMessage<?> command, Aggregate<T> createdAggregate)
command has created the given aggregate.
 This implementation returns the identifier of the created aggregate.
 This method may be overridden to change the return value of this Command Handler
command - The command being executedcreatedAggregate - The aggregate that has been created as a result of the commandpublic Set<String> supportedCommandNames()
SupportedCommandNamesAwaresupportedCommandNames in interface SupportedCommandNamesAwareCopyright © 2010–2018. All rights reserved.