T
- The type of Aggregate created by this factorypublic abstract class AbstractAggregateFactory<T> extends Object implements AggregateFactory<T>
Modifier | Constructor and Description |
---|---|
protected |
AbstractAggregateFactory(Class<T> aggregateBaseType)
Initialize an aggregateFactory for the given
aggregateBaseType . |
Modifier and Type | Method and Description |
---|---|
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 and 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.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–2018. All rights reserved.