org.axonframework.eventsourcing
Class AbstractAggregateFactory<T extends EventSourcedAggregateRoot>
java.lang.Object
org.axonframework.eventsourcing.AbstractAggregateFactory<T>
- Type Parameters:
T
- The type of Aggregate created by this factory
- All Implemented Interfaces:
- AggregateFactory<T>
- Direct Known Subclasses:
- GenericAggregateFactory, SpringPrototypeAggregateFactory
public abstract class AbstractAggregateFactory<T extends EventSourcedAggregateRoot>
- extends Object
- implements AggregateFactory<T>
Abstract AggregateFactory implementation that is aware of snapshot events. If an incoming event is not a snapshot
event, creation is delegated to the subclass.
- Since:
- 2.0
- Author:
- Allard Buijze
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractAggregateFactory
protected AbstractAggregateFactory()
AbstractAggregateFactory
protected AbstractAggregateFactory(ParameterResolverFactory parameterResolverFactory)
createAggregate
public final T createAggregate(Object aggregateIdentifier,
DomainEventMessage<?> firstEvent)
- Description copied from interface:
AggregateFactory
- Instantiate the aggregate 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.
- Specified by:
createAggregate
in interface AggregateFactory<T extends EventSourcedAggregateRoot>
- 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 ready for initialization using a DomainEventStream.
postProcessInstance
protected T postProcessInstance(T aggregate)
- Perform any processing that must be done on an aggregate instance that was reconstructed from a Snapshot
Event. Implementations may choose to modify the existing instance, or return a new instance.
This method can be safely overridden. This implementation does nothing.
- Parameters:
aggregate
- The aggregate to post-process.
- Returns:
- The aggregate to initialize with the Event Stream
doCreateAggregate
protected abstract T doCreateAggregate(Object aggregateIdentifier,
DomainEventMessage firstEvent)
- Create an uninitialized Aggregate instance with the given
aggregateIdentifier
. The given
firstEvent
can be used to define the requirements of the aggregate to create.
The given firstEvent
is never a snapshot event.
- Parameters:
aggregateIdentifier
- The identifier of the aggregate to createfirstEvent
- The first event in the Event Stream of the Aggregate
- Returns:
- The aggregate instance to initialize with the Event Stream
Copyright © 2010-2016. All Rights Reserved.