Class SpringAggregateSnapshotter

java.lang.Object
org.axonframework.eventsourcing.AbstractSnapshotter
org.axonframework.eventsourcing.AggregateSnapshotter
org.axonframework.spring.eventsourcing.SpringAggregateSnapshotter
All Implemented Interfaces:
org.axonframework.eventsourcing.Snapshotter, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

public class SpringAggregateSnapshotter extends org.axonframework.eventsourcing.AggregateSnapshotter implements org.springframework.context.ApplicationContextAware
Snapshotter implementation that uses the AggregateRoot as state for the snapshot. Unlike the AggregateSnapshotter, this implementation lazily retrieves AggregateFactories from the Application Context when snapshot requests are made.

Instead of configuring directly, consider using the SpringAggregateSnapshotterFactoryBean, which configures this class using values available in the application context.

Since:
3.0
Author:
Allard Buijze
See Also:
  • Constructor Details

  • Method Details

    • builder

      public static SpringAggregateSnapshotter.Builder builder()
      Instantiate a Builder to be able to create a SpringAggregateSnapshotter. The AggregateFactory instances are lazily retrieved by the ApplicationContext.

      The Executor is defaulted to an DirectExecutor.INSTANCE, the TransactionManager defaults to a NoTransactionManager and the SpanFactory defaults to a NoOpSpanFactory. Additionally, this Builder has convenience functions to default the ParameterResolverFactory and HandlerDefinition based on instances of these available on the classpath in case these are not provided (respectively AggregateSnapshotter.Builder.buildParameterResolverFactory() and AggregateSnapshotter.Builder.buildHandlerDefinition()). Upon instantiation of a AggregateSnapshotter, it is recommended to use these function to set those fields.

      The EventStore is a hard requirement and as such should be provided.

      Returns:
      a Builder to be able to create a SpringAggregateSnapshotter
      See Also:
      • ClasspathParameterResolverFactory
      • ClasspathHandlerDefinition
    • getAggregateFactory

      protected org.axonframework.eventsourcing.AggregateFactory<?> getAggregateFactory(Class<?> aggregateType)
      Overrides:
      getAggregateFactory in class org.axonframework.eventsourcing.AggregateSnapshotter
    • setApplicationContext

      public void setApplicationContext(@Nonnull org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException