Package org.axonframework.eventsourcing
Interface AggregateFactory<T>
- Type Parameters:
T- The type of aggregate this factory creates
- All Known Implementing Classes:
AbstractAggregateFactory,GenericAggregateFactory,SpringPrototypeAggregateFactory
public interface AggregateFactory<T>
Interface describing objects capable of creating instances of aggregates to be initialized with an event stream.
Implementation note: to make sure an implementation handles snapshot events correctly, consider extending
AbstractAggregateFactory.- Since:
- 0.6
- Author:
- Allard Buijze
-
Method Summary
Modifier and TypeMethodDescriptioncreateAggregateRoot(String aggregateIdentifier, DomainEventMessage<?> firstEvent) Instantiate the aggregate root using the given aggregate identifier and first event.Returns the type of aggregate this factory creates.
-
Method Details
-
createAggregateRoot
Instantiate the aggregate root using the given aggregate identifier and first event. The first event of the event stream is passed to allow the factory to identify the actual implementation type of the aggregate to create. The first event can be either the event that created the aggregate or, when using event sourcing, a snapshot event. In either case, the event should be designed, such that these events contain enough information to deduct the actual aggregate type.- Parameters:
aggregateIdentifier- the aggregate identifier of the aggregate to instantiatefirstEvent- The first event in the event stream. This is either the event generated during creation of the aggregate, or a snapshot event- Returns:
- an aggregate root ready for initialization using a DomainEventStream.
-
getAggregateType
Returns the type of aggregate this factory creates. All instances created by this factory must be aninstanceOfthis type.- Returns:
- The type of aggregate created by this factory
-