Class SpringAggregateSnapshotter
- All Implemented Interfaces:
Snapshotter,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class to instantiate aSpringAggregateSnapshotter. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate aSpringAggregateSnapshotterbased on the fields contained in theSpringAggregateSnapshotter.Builder. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Instantiate a Builder to be able to create aSpringAggregateSnapshotter.protected AggregateFactory<?> getAggregateFactory(Class<?> aggregateType) Returns the AggregateFactory registered for the givenaggregateType, ornullif no such AggregateFactory is known.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) Methods inherited from class org.axonframework.eventsourcing.AggregateSnapshotter
createSnapshot, registerAggregateFactoryMethods inherited from class org.axonframework.eventsourcing.AbstractSnapshotter
createSnapshotterTask, getEventStore, getExecutor, scheduleSnapshot
-
Constructor Details
-
SpringAggregateSnapshotter
Instantiate aSpringAggregateSnapshotterbased on the fields contained in theSpringAggregateSnapshotter.Builder. TheAggregateFactoryinstances are lazily retrieved by theApplicationContext.Will assert that the
EventStore,ParameterResolverFactoryandHandlerDefinitionare notnull, and will throw anAxonConfigurationExceptionif any of them isnull.- Parameters:
builder- theSpringAggregateSnapshotter.Builderused to instantiate aSpringAggregateSnapshotterinstance
-
-
Method Details
-
builder
Instantiate a Builder to be able to create aSpringAggregateSnapshotter. TheAggregateFactoryinstances are lazily retrieved by theApplicationContext.The
Executoris defaulted to anDirectExecutor.INSTANCE, theTransactionManagerdefaults to aNoTransactionManagerand theSpanFactorydefaults to aNoOpSpanFactory. Additionally, this Builder has convenience functions to default theParameterResolverFactoryandHandlerDefinitionbased on instances of these available on the classpath in case these are not provided (respectivelyAggregateSnapshotter.Builder.buildParameterResolverFactory()andAggregateSnapshotter.Builder.buildHandlerDefinition()). Upon instantiation of aAggregateSnapshotter, it is recommended to use these function to set those fields.The
EventStoreis a hard requirement and as such should be provided.- Returns:
- a Builder to be able to create a
SpringAggregateSnapshotter - See Also:
-
getAggregateFactory
Description copied from class:AggregateSnapshotterReturns the AggregateFactory registered for the givenaggregateType, ornullif no such AggregateFactory is known.Subclasses may override this method to enhance how AggregateFactories are retrieved. They may choose to
AggregateSnapshotter.registerAggregateFactory(AggregateFactory)if it hasn't been found using this implementation.- Overrides:
getAggregateFactoryin classAggregateSnapshotter- Parameters:
aggregateType- The type to get the AggregateFactory for- Returns:
- the appropriate AggregateFactory, or
nullif not found
-
setApplicationContext
public void setApplicationContext(@Nonnull org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-