public abstract class AbstractSnapshotTrigger extends Object implements SnapshotTrigger, Serializable
SnapshotTrigger
that schedules snapshots on
the Unit of Work. Actual logic when to schedule a snapshot should be provided by a subclass.Modifier | Constructor and Description |
---|---|
protected |
AbstractSnapshotTrigger(Snapshotter snapshotter,
Class<?> aggregateType)
|
Modifier and Type | Method and Description |
---|---|
void |
eventHandled(EventMessage<?> msg)
Invoked when an event is handled by an aggregate.
|
protected abstract boolean |
exceedsThreshold()
This method is used to determine if a new snapshot should be created
|
void |
initializationFinished()
Invoked when the initialization of the aggregate based on passed events is completed.
|
protected abstract void |
reset()
This method is used to reset all the variables that are used to check if a threshold has been exceeded
|
void |
setSnapshotter(Snapshotter snapshotter)
Sets the snapshotter
|
protected AbstractSnapshotTrigger(Snapshotter snapshotter, Class<?> aggregateType)
snapshotter
- the Snapshotter
for scheduling snapshotsaggregateType
- the of the aggregate that is creating a snapshot
public void eventHandled(EventMessage<?> msg)
SnapshotTrigger
DomainEventMessage
, 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.eventHandled
in interface SnapshotTrigger
msg
- The message handled by the aggregatepublic void initializationFinished()
SnapshotTrigger
SnapshotTrigger.eventHandled(EventMessage)
involves an event being applied on "current state".initializationFinished
in interface SnapshotTrigger
public void setSnapshotter(Snapshotter snapshotter)
snapshotter
- The Snapshotter
for scheduling snapshots.protected abstract boolean exceedsThreshold()
protected abstract void reset()
Copyright © 2010–2022. All rights reserved.