Class AggregateSnapshotter
- All Implemented Interfaces:
Snapshotter
- Direct Known Subclasses:
SpringAggregateSnapshotter
- Since:
- 0.6
- Author:
- Allard Buijze
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class to instantiate aAggregateSnapshotter. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate aAggregateSnapshotterbased on the fields contained in theAggregateSnapshotter.Builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic AggregateSnapshotter.Builderbuilder()Instantiate a Builder to be able to create aAggregateSnapshotter.protected DomainEventMessagecreateSnapshot(Class<?> aggregateType, String aggregateIdentifier, DomainEventStream eventStream) Creates a snapshot event for an aggregate of which passed events are available in the giveneventStream.protected AggregateFactory<?> getAggregateFactory(Class<?> aggregateType) Returns the AggregateFactory registered for the givenaggregateType, ornullif no such AggregateFactory is known.protected voidregisterAggregateFactory(AggregateFactory<?> aggregateFactory) Registers the givenaggregateFactorywith this snapshotter.Methods inherited from class org.axonframework.eventsourcing.AbstractSnapshotter
createSnapshotterTask, getEventStore, getExecutor, scheduleSnapshot
-
Constructor Details
-
AggregateSnapshotter
Instantiate aAggregateSnapshotterbased on the fields contained in theAggregateSnapshotter.Builder.Will assert that the
EventStore,ParameterResolverFactoryandHandlerDefinitionare notnull, and will throw anAxonConfigurationExceptionif any of them isnull. TheSpanFactoryis defaulted to aNoOpSpanFactory.- Parameters:
builder- theAggregateSnapshotter.Builderused to instantiate aAggregateSnapshotterinstance
-
-
Method Details
-
builder
Instantiate a Builder to be able to create aAggregateSnapshotter.The
Executoris defaulted to anDirectExecutor.INSTANCEand theTransactionManagerdefaults to aNoTransactionManager. Additionally, this Builder has convenience functions to default theParameterResolverFactoryandHandlerDefinitionbased on instances of these available on the classpath in case these are not provided (respectivelyAggregateSnapshotter.Builder.buildParameterResolverFactory()andAggregateSnapshotter.Builder.buildHandlerDefinition()). Upon instantiation of aAggregateSnapshotter, it is recommended to use these function to set those fields.The
EventStoreis a hard requirement and as such should be provided.- Returns:
- a Builder to be able to create a
AggregateSnapshotter - See Also:
-
createSnapshot
protected DomainEventMessage createSnapshot(Class<?> aggregateType, String aggregateIdentifier, DomainEventStream eventStream) Description copied from class:AbstractSnapshotterCreates a snapshot event for an aggregate of which passed events are available in the giveneventStream. May returnnullto indicate a snapshot event is not necessary or appropriate for the given event stream.- Specified by:
createSnapshotin classAbstractSnapshotter- Parameters:
aggregateType- The aggregate's type identifieraggregateIdentifier- The identifier of the aggregate to create a snapshot foreventStream- The event stream containing the aggregate's past events- Returns:
- the snapshot event for the given events, or
nullif none should be stored.
-
getAggregateFactory
Returns the AggregateFactory registered for the givenaggregateType, ornullif no such AggregateFactory is known.Subclasses 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.- Parameters:
aggregateType- The type to get the AggregateFactory for- Returns:
- the appropriate AggregateFactory, or
nullif not found
-
registerAggregateFactory
Registers the givenaggregateFactorywith this snapshotter. If a factory for this type was already registered, it is overwritten with this one.- Parameters:
aggregateFactory- the AggregateFactory to register
-