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 Details

  • Method Details

    • eventHandled

      public void eventHandled(@Nonnull EventMessage<?> msg)
      Description copied from interface: SnapshotTrigger
      Invoked when an event is handled by an aggregate. While these messages usually extend 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.
      Specified by:
      eventHandled in interface SnapshotTrigger
      Parameters:
      msg - The message handled by the aggregate
    • initializationFinished

      public void initializationFinished()
      Description copied from interface: SnapshotTrigger
      Invoked when the initialization of the aggregate based on passed events is completed. Any subsequent invocation of SnapshotTrigger.eventHandled(EventMessage) involves an event being applied on "current state".
      Specified by:
      initializationFinished in interface SnapshotTrigger
    • setSnapshotter

      public void setSnapshotter(Snapshotter snapshotter)
      Sets the snapshotter
      Parameters:
      snapshotter - The Snapshotter for 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