Package org.axonframework.eventsourcing
Class AbstractSnapshotter
java.lang.Object
org.axonframework.eventsourcing.AbstractSnapshotter
- All Implemented Interfaces:
Snapshotter
- Direct Known Subclasses:
AggregateSnapshotter
Abstract implementation of the
Snapshotter that uses a task executor to
creates snapshots. Actual snapshot creation logic should be provided by a subclass.- Since:
- 0.6
- Author:
- Allard Buijze
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAbstract Builder class to instantiateAbstractSnapshotterimplementations. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate aAbstractSnapshotterbased on the fields contained in theAbstractSnapshotter.Builder. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract DomainEventMessagecreateSnapshot(Class<?> aggregateType, String aggregateIdentifier, DomainEventStream eventStream) Creates a snapshot event for an aggregate of which passed events are available in the giveneventStream.protected RunnablecreateSnapshotterTask(Class<?> aggregateType, String aggregateIdentifier) Creates an instance of a task that contains the actual snapshot creation logic.protected EventStoreReturns the event store this snapshotter uses to load domain events and store snapshot events.protected ExecutorReturns the executor that executes snapshot taking tasks.voidscheduleSnapshot(Class<?> aggregateType, String aggregateIdentifier) Schedules snapshot taking for an aggregate with givenaggregateIdentifier.
-
Constructor Details
-
AbstractSnapshotter
Instantiate aAbstractSnapshotterbased on the fields contained in theAbstractSnapshotter.Builder.Will assert that the
EventStoreis notnull, and will throw anAxonConfigurationExceptionif it isnull.- Parameters:
builder- theAbstractSnapshotter.Builderused to instantiate aAbstractSnapshotterinstance
-
-
Method Details
-
scheduleSnapshot
Description copied from interface:SnapshotterSchedules snapshot taking for an aggregate with givenaggregateIdentifier. The implementation may choose to process this call synchronously (i.e. in the caller's thread), asynchronously, or ignore the call altogether.- Specified by:
scheduleSnapshotin interfaceSnapshotter- Parameters:
aggregateType- the type of the aggregate to take the snapshot foraggregateIdentifier- The identifier of the aggregate to take the snapshot for
-
createSnapshotterTask
Creates an instance of a task that contains the actual snapshot creation logic.- Parameters:
aggregateType- The type of the aggregate to create a snapshot foraggregateIdentifier- The identifier of the aggregate to create a snapshot for- Returns:
- the task containing snapshot creation logic
-
createSnapshot
protected abstract DomainEventMessage createSnapshot(Class<?> aggregateType, String aggregateIdentifier, DomainEventStream eventStream) Creates 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.- 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.
-
getEventStore
Returns the event store this snapshotter uses to load domain events and store snapshot events.- Returns:
- the event store this snapshotter uses to load domain events and store snapshot events.
-
getExecutor
Returns the executor that executes snapshot taking tasks.- Returns:
- the executor that executes snapshot taking tasks.
-