Package org.axonframework.eventsourcing
Class AbstractSnapshotTrigger
java.lang.Object
org.axonframework.eventsourcing.AbstractSnapshotTrigger
- All Implemented Interfaces:
Serializable,SnapshotTrigger
public abstract class AbstractSnapshotTrigger
extends Object
implements SnapshotTrigger, Serializable
Abstract implementation of the
SnapshotTrigger that schedules snapshots on
the Unit of Work. Actual logic when to schedule a snapshot should be provided by a subclass.- Since:
- 4.4.4
- Author:
- Yvonne Ceelie
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSnapshotTrigger(Snapshotter snapshotter, Class<?> aggregateType) -
Method Summary
Modifier and TypeMethodDescriptionvoideventHandled(EventMessage<?> msg) Invoked when an event is handled by an aggregate.protected abstract booleanThis method is used to determine if a new snapshot should be createdvoidInvoked when the initialization of the aggregate based on passed events is completed.protected abstract voidreset()This method is used to reset all the variables that are used to check if a threshold has been exceededvoidsetSnapshotter(Snapshotter snapshotter) Sets the snapshotter
-
Constructor Details
-
AbstractSnapshotTrigger
- Parameters:
snapshotter- theSnapshotterfor scheduling snapshotsaggregateType- theof the aggregate that is creating a snapshot
-
-
Method Details
-
eventHandled
Description copied from interface:SnapshotTriggerInvoked when an event is handled by an aggregate. While these messages usually extendDomainEventMessage, this is not guaranteed. The given message can either be a historic Message from the Event Store, or one that has been just applied by the aggregate.- Specified by:
eventHandledin interfaceSnapshotTrigger- Parameters:
msg- The message handled by the aggregate
-
initializationFinished
public void initializationFinished()Description copied from interface:SnapshotTriggerInvoked when the initialization of the aggregate based on passed events is completed. Any subsequent invocation ofSnapshotTrigger.eventHandled(EventMessage)involves an event being applied on "current state".- Specified by:
initializationFinishedin interfaceSnapshotTrigger
-
setSnapshotter
Sets the snapshotter- Parameters:
snapshotter- TheSnapshotterfor scheduling snapshots.
-
exceedsThreshold
protected abstract boolean exceedsThreshold()This method is used to determine if a new snapshot should be created- Returns:
- true if the threshold has been exceeded
-
reset
protected abstract void reset()This method is used to reset all the variables that are used to check if a threshold has been exceeded
-