Class AggregateSnapshotter.Builder
- Direct Known Subclasses:
SpringAggregateSnapshotter.Builder
- Enclosing class:
AggregateSnapshotter
AggregateSnapshotter.
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
buildParameterResolverFactory() and 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.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaggregateFactories(List<AggregateFactory<?>> aggregateFactories) Sets theaggregateFactoriessupported by this snapshotter.aggregateFactories(AggregateFactory<?>... aggregateFactories) Sets theaggregateFactoriessupported by this snapshotter.build()Initializes aAggregateSnapshotteras specified through this Builder.protected HandlerDefinitionReturn the setHandlerDefinition, or create and return it if it isnull.protected ParameterResolverFactoryReturn the setParameterResolverFactory, or create and return it if it isnull.eventStore(EventStore eventStore) Sets theEventStoreinstance which thisAbstractSnapshotterimplementation will store snapshots in.Sets theExecutorwhich handles the actual snapshot creation process.handlerDefinition(HandlerDefinition handlerDefinition) Sets theHandlerDefinitionused to create concrete handlers in the snapshot aggregate this snapshotter creates.parameterResolverFactory(ParameterResolverFactory parameterResolverFactory) Sets theParameterResolverFactoryused to resolve parameter values for annotated handlers in the snapshot aggregate this snapshotter creates.repositoryProvider(RepositoryProvider repositoryProvider) Sets theRepositoryProviderprovided to the snapshot aggregates this snapshotter creates for correct instantiation.spanFactory(SnapshotterSpanFactory spanFactory) Sets theSnapshotterSpanFactoryimplementation to use for providing tracing capabilities.transactionManager(TransactionManager transactionManager) Sets theTransactionManagerused to manage the transaction around storing the snapshot.protected voidvalidate()Validates whether the fields contained in this Builder are set accordingly.Methods inherited from class org.axonframework.eventsourcing.AbstractSnapshotter.Builder
spanFactory
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
spanFactory
Description copied from class:AbstractSnapshotter.BuilderSets theSnapshotterSpanFactoryimplementation to use for providing tracing capabilities. Defaults to aDefaultSnapshotterSpanFactorywith aNoOpSpanFactoryby default, which provides no tracing capabilities.- Overrides:
spanFactoryin classAbstractSnapshotter.Builder- Parameters:
spanFactory- TheSpanFactoryimplementation.- Returns:
- The current Builder instance, for fluent interfacing.
-
eventStore
Description copied from class:AbstractSnapshotter.BuilderSets theEventStoreinstance which thisAbstractSnapshotterimplementation will store snapshots in.- Overrides:
eventStorein classAbstractSnapshotter.Builder- Parameters:
eventStore- theEventStoreinstance which thisAbstractSnapshotterimplementation will store snapshots in- Returns:
- the current Builder instance, for fluent interfacing
-
executor
Description copied from class:AbstractSnapshotter.BuilderSets theExecutorwhich handles the actual snapshot creation process. Defaults to aDirectExecutor.- Overrides:
executorin classAbstractSnapshotter.Builder- Parameters:
executor- anExecutorwhich handles the actual snapshot creation process- Returns:
- the current Builder instance, for fluent interfacing
-
transactionManager
Description copied from class:AbstractSnapshotter.BuilderSets theTransactionManagerused to manage the transaction around storing the snapshot. Defaults to aNoTransactionManager.- Overrides:
transactionManagerin classAbstractSnapshotter.Builder- Parameters:
transactionManager- theTransactionManagerused to manage the transaction around storing the snapshot- Returns:
- the current Builder instance, for fluent interfacing
-
aggregateFactories
Sets theaggregateFactoriessupported by this snapshotter. TheAggregateFactoryinstances are used to create the relevant Aggregate Root instance, which represent the snapshots.- Parameters:
aggregateFactories- an array ofAggregateFactoryinstances which this snapshotter will support- Returns:
- the current Builder instance, for fluent interfacing
-
aggregateFactories
public AggregateSnapshotter.Builder aggregateFactories(List<AggregateFactory<?>> aggregateFactories) Sets theaggregateFactoriessupported by this snapshotter. TheAggregateFactoryinstances are used to create the relevant Aggregate Root instance, which represent the snapshots.- Parameters:
aggregateFactories- aListofAggregateFactoryinstances which this snapshotter will support- Returns:
- the current Builder instance, for fluent interfacing
-
repositoryProvider
Sets theRepositoryProviderprovided to the snapshot aggregates this snapshotter creates for correct instantiation.- Parameters:
repositoryProvider- theRepositoryProviderprovided to the snapshot aggregates this snapshotter creates for correct instantiation- Returns:
- the current Builder instance, for fluent interfacing
-
parameterResolverFactory
public AggregateSnapshotter.Builder parameterResolverFactory(ParameterResolverFactory parameterResolverFactory) Sets theParameterResolverFactoryused to resolve parameter values for annotated handlers in the snapshot aggregate this snapshotter creates.- Parameters:
parameterResolverFactory- theParameterResolverFactoryused to resolve parameter values for annotated handlers in the snapshot aggregate this snapshotter creates- Returns:
- the current Builder instance, for fluent interfacing
-
handlerDefinition
Sets theHandlerDefinitionused to create concrete handlers in the snapshot aggregate this snapshotter creates.- Parameters:
handlerDefinition- theHandlerDefinitionused to create concrete handlers in the snapshot aggregate this snapshotter creates- Returns:
- the current Builder instance, for fluent interfacing
-
build
Initializes aAggregateSnapshotteras specified through this Builder.- Returns:
- a
AggregateSnapshotteras specified through this Builder
-
buildParameterResolverFactory
Return the setParameterResolverFactory, or create and return it if it isnull. In case it has not been set yet, a ParameterResolverFactory is created by calling theClasspathParameterResolverFactory.forClass(Class)function, either providing theAggregateSnapshottertype or the firstAggregateFactoryit's class as input.Note: it is recommended to use this function when retrieving the ParameterResolverFactory as it ensure it is non-null.
- Returns:
- the set or instantiated
ParameterResolverFactory
-
buildHandlerDefinition
Return the setHandlerDefinition, or create and return it if it isnull. In case it has not been set yet, a HandlerDefinition is created by calling theClasspathHandlerDefinition.forClass(Class)function, either providing theAggregateSnapshottertype or the firstAggregateFactoryit's class as input.Note: it is recommended to use this function when retrieving the HandlerDefinition as it ensure it is non-null.
- Returns:
- the set or instantiated
ParameterResolverFactory
-
validate
Validates whether the fields contained in this Builder are set accordingly.- Overrides:
validatein classAbstractSnapshotter.Builder- Throws:
AxonConfigurationException- if one field is asserted to be incorrect according to the Builder's specifications
-