T
- the type of aggregate this handler handles commands forpublic class AggregateAnnotationCommandHandler<T extends AggregateRoot> extends Object implements Subscribable
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,
CommandBus commandBus)
Initializes an AnnotationCommandHandler based on the annotations on given
aggregateType , to be
registered on the given commandBus . |
AggregateAnnotationCommandHandler(Class<T> aggregateType,
Repository<T> repository,
CommandBus commandBus,
CommandTargetResolver commandTargetResolver)
Initializes an AnnotationCommandHandler based on the annotations on given
aggregateType , to be
registered on the given commandBus . |
Modifier and Type | Method and Description |
---|---|
void |
subscribe()
Subscribe this instance with its configured component.
|
static <T extends AggregateRoot> |
subscribe(Class<T> aggregateType,
Repository<T> repository,
CommandBus commandBus)
Subscribe a handler for the given aggregate type to the given command bus.
|
static <T extends AggregateRoot> |
subscribe(Class<T> aggregateType,
Repository<T> repository,
CommandBus commandBus,
CommandTargetResolver commandTargetResolver)
Subscribe a handler for the given aggregate type to the given command bus.
|
void |
unsubscribe()
Unsubscribe this instance from its subscribed component.
|
public AggregateAnnotationCommandHandler(Class<T> aggregateType, Repository<T> repository, CommandBus commandBus)
aggregateType
, to be
registered on the given commandBus
.aggregateType
- The type of aggregaterepository
- The repository providing access to aggregate instancescommandBus
- The command bus to register command handlers topublic AggregateAnnotationCommandHandler(Class<T> aggregateType, Repository<T> repository, CommandBus commandBus, CommandTargetResolver commandTargetResolver)
aggregateType
, to be
registered on the given commandBus
.aggregateType
- The type of aggregaterepository
- The repository providing access to aggregate instancescommandBus
- The command bus to register command handlers tocommandTargetResolver
- The target resolution strategypublic static <T extends AggregateRoot> AggregateAnnotationCommandHandler subscribe(Class<T> aggregateType, Repository<T> repository, CommandBus commandBus)
T
- The type of aggregate this handler handles commands foraggregateType
- The type of aggregaterepository
- The repository providing access to aggregate instancescommandBus
- The command bus to register command handlers topublic static <T extends AggregateRoot> AggregateAnnotationCommandHandler subscribe(Class<T> aggregateType, Repository<T> repository, CommandBus commandBus, CommandTargetResolver commandTargetResolver)
T
- The type of aggregate this handler handles commands foraggregateType
- The type of aggregaterepository
- The repository providing access to aggregate instancescommandBus
- The command bus to register command handlers tocommandTargetResolver
- The target resolution strategy@PreDestroy public void unsubscribe()
Subscribable
unsubscribe
in interface Subscribable
@PostConstruct public void subscribe()
Subscribable
subscribe
in interface Subscribable
Copyright © 2010-2013. All Rights Reserved.