public class AggregateSnapshotter extends AbstractSnapshotter
Modifier and Type | Class and Description |
---|---|
static class |
AggregateSnapshotter.Builder
Builder class to instantiate a
AggregateSnapshotter . |
Modifier | Constructor and Description |
---|---|
protected |
AggregateSnapshotter(AggregateSnapshotter.Builder builder)
Instantiate a
AggregateSnapshotter based on the fields contained in the AggregateSnapshotter.Builder . |
Modifier and Type | Method and Description |
---|---|
static AggregateSnapshotter.Builder |
builder()
Instantiate a Builder to be able to create a
AggregateSnapshotter . |
protected DomainEventMessage |
createSnapshot(Class<?> aggregateType,
String aggregateIdentifier,
DomainEventStream eventStream)
Creates a snapshot event for an aggregate of which passed events are available in the given
eventStream . |
protected AggregateFactory<?> |
getAggregateFactory(Class<?> aggregateType)
Returns the AggregateFactory registered for the given
aggregateType , or null if no such
AggregateFactory is known. |
protected void |
registerAggregateFactory(AggregateFactory<?> aggregateFactory)
Registers the given
aggregateFactory with this snapshotter. |
createSnapshotterTask, getEventStore, getExecutor, scheduleSnapshot
protected AggregateSnapshotter(AggregateSnapshotter.Builder builder)
AggregateSnapshotter
based on the fields contained in the AggregateSnapshotter.Builder
.
Will assert that the EventStore
, ParameterResolverFactory
and HandlerDefinition
are not
null
, and will throw an AxonConfigurationException
if any of them is null
.
builder
- the AggregateSnapshotter.Builder
used to instantiate a AggregateSnapshotter
instancepublic static AggregateSnapshotter.Builder builder()
AggregateSnapshotter
.
The Executor
is defaulted to an DirectExecutor.INSTANCE
and the
TransactionManager
defaults to a NoTransactionManager
.
Additionally, this Builder has convenience functions to default the ParameterResolverFactory
and
HandlerDefinition
based on instances of these available on the classpath in case these are not provided
(respectively AggregateSnapshotter.Builder.buildParameterResolverFactory()
and AggregateSnapshotter.Builder.buildHandlerDefinition()
).
Upon instantiation of a AggregateSnapshotter
, it is recommended to use these function to set those
fields.
The EventStore
is a hard requirement and as such should be provided.
AggregateSnapshotter
ClasspathParameterResolverFactory
,
ClasspathHandlerDefinition
protected DomainEventMessage createSnapshot(Class<?> aggregateType, String aggregateIdentifier, DomainEventStream eventStream)
AbstractSnapshotter
eventStream
.
May return null
to indicate a snapshot event is not necessary or appropriate for the given event stream.createSnapshot
in class AbstractSnapshotter
aggregateType
- The aggregate's type identifieraggregateIdentifier
- The identifier of the aggregate to create a snapshot foreventStream
- The event stream containing the aggregate's past eventsnull
if none should be stored.protected AggregateFactory<?> getAggregateFactory(Class<?> aggregateType)
aggregateType
, or null
if no such
AggregateFactory is known.
Sublasses may override this method to enhance how AggregateFactories are retrieved. They may choose to
registerAggregateFactory(AggregateFactory)
if it hasn't been found using this implementation.
aggregateType
- The type to get the AggregateFactory fornull
if not foundprotected void registerAggregateFactory(AggregateFactory<?> aggregateFactory)
aggregateFactory
with this snapshotter. If a factory for this type was already
registered, it is overwritten with this one.aggregateFactory
- the AggregateFactory to registerCopyright © 2010–2022. All rights reserved.