T
- The type of Aggregate created by this factorypublic abstract class AbstractAggregateFactory<T> extends Object implements AggregateFactory<T>
Modifier | Constructor and Description |
---|---|
protected |
AbstractAggregateFactory(AggregateModel<T> aggregateModel)
Initializes an Aggregate Factory for the given
aggregateModel . |
protected |
AbstractAggregateFactory(Class<T> aggregateBaseType)
Initialize an Aggregate Factory for the given
aggregateBaseType . |
Modifier and Type | Method and Description |
---|---|
protected AggregateModel<T> |
aggregateModel()
Gets the aggregate model.
|
T |
createAggregateRoot(String aggregateIdentifier,
DomainEventMessage<?> firstEvent)
Instantiate the aggregate root using the given aggregate identifier and first event.
|
protected abstract T |
doCreateAggregate(String aggregateIdentifier,
DomainEventMessage firstEvent)
Create an uninitialized Aggregate instance with the given
aggregateIdentifier . |
Class<T> |
getAggregateType()
Returns the type of aggregate this factory creates.
|
protected T |
postProcessInstance(T aggregate)
Perform any processing that must be done on an aggregate instance that was reconstructed from a Snapshot
Event.
|
protected AbstractAggregateFactory(Class<T> aggregateBaseType)
aggregateBaseType
. If a first event is an instance of this
aggregateBaseType
, it is recognised as a snapshot event. Otherwise, the subclass is asked to instantiate
a new aggregate root instance based on the first event.aggregateBaseType
- The base type of the aggregate roots created by this instance.protected AbstractAggregateFactory(AggregateModel<T> aggregateModel)
aggregateModel
. If a first event is an instance of any
aggregate root within this aggregateModel
, it is recognised as a snapshot event. Otherwise, the subclass
is asked to instantiate a new aggregate root instance based on the first event.aggregateModel
- The model of aggregate to be created by this factoryprotected AggregateModel<T> aggregateModel()
public final T createAggregateRoot(String aggregateIdentifier, DomainEventMessage<?> firstEvent)
AggregateFactory
createAggregateRoot
in interface AggregateFactory<T>
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 eventprotected T postProcessInstance(T aggregate)
aggregate
- The aggregate to post-process.protected abstract T doCreateAggregate(String aggregateIdentifier, DomainEventMessage firstEvent)
aggregateIdentifier
. The given
firstEvent
can be used to define the requirements of the aggregate to create.
The given firstEvent
is never a snapshot event.aggregateIdentifier
- The identifier of the aggregate to createfirstEvent
- The first event in the Event Stream of the Aggregatepublic Class<T> getAggregateType()
AggregateFactory
instanceOf
this type.getAggregateType
in interface AggregateFactory<T>
Copyright © 2010–2020. All rights reserved.