public static class AggregateSnapshotter.Builder extends AbstractSnapshotter.Builder
AggregateSnapshotter
.
The Executor
is defaulted to an DirectExecutor.INSTANCE
and the
TransactionManager
defaults to a NoTransactionManager
.
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.
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
AggregateSnapshotter.Builder |
aggregateFactories(AggregateFactory<?>... aggregateFactories)
Sets the
aggregateFactories supported by this snapshotter. |
AggregateSnapshotter.Builder |
aggregateFactories(List<AggregateFactory<?>> aggregateFactories)
Sets the
aggregateFactories supported by this snapshotter. |
AggregateSnapshotter |
build()
Initializes a
AggregateSnapshotter as specified through this Builder. |
protected HandlerDefinition |
buildHandlerDefinition()
Return the set
HandlerDefinition , or create and return it if it is null . |
protected ParameterResolverFactory |
buildParameterResolverFactory()
Return the set
ParameterResolverFactory , or create and return it if it is null . |
AggregateSnapshotter.Builder |
eventStore(EventStore eventStore)
Sets the
EventStore instance which this AbstractSnapshotter implementation will store
snapshots in. |
AggregateSnapshotter.Builder |
executor(Executor executor)
Sets the
Executor which handles the actual snapshot creation process. |
AggregateSnapshotter.Builder |
handlerDefinition(HandlerDefinition handlerDefinition)
Sets the
HandlerDefinition used to create concrete handlers in the snapshot aggregate this
snapshotter creates. |
AggregateSnapshotter.Builder |
parameterResolverFactory(ParameterResolverFactory parameterResolverFactory)
Sets the
ParameterResolverFactory used to resolve parameter values for annotated handlers in the
snapshot aggregate this snapshotter creates. |
AggregateSnapshotter.Builder |
repositoryProvider(RepositoryProvider repositoryProvider)
Sets the
RepositoryProvider provided to the snapshot aggregates this snapshotter creates for correct
instantiation. |
AggregateSnapshotter.Builder |
transactionManager(TransactionManager transactionManager)
Sets the
TransactionManager used to manage the transaction around storing the snapshot. |
protected void |
validate()
Validates whether the fields contained in this Builder are set accordingly.
|
public AggregateSnapshotter.Builder eventStore(EventStore eventStore)
AbstractSnapshotter.Builder
EventStore
instance which this AbstractSnapshotter
implementation will store
snapshots in.eventStore
in class AbstractSnapshotter.Builder
eventStore
- the EventStore
instance which this AbstractSnapshotter
implementation will
store snapshots inpublic AggregateSnapshotter.Builder executor(Executor executor)
AbstractSnapshotter.Builder
Executor
which handles the actual snapshot creation process. Defaults to a
DirectExecutor
.executor
in class AbstractSnapshotter.Builder
executor
- an Executor
which handles the actual snapshot creation processpublic AggregateSnapshotter.Builder transactionManager(TransactionManager transactionManager)
AbstractSnapshotter.Builder
TransactionManager
used to manage the transaction around storing the snapshot. Defaults to a
NoTransactionManager
.transactionManager
in class AbstractSnapshotter.Builder
transactionManager
- the TransactionManager
used to manage the transaction around storing the
snapshotpublic AggregateSnapshotter.Builder aggregateFactories(AggregateFactory<?>... aggregateFactories)
aggregateFactories
supported by this snapshotter. The AggregateFactory
instances are
used to create the relevant Aggregate Root instance, which represent the snapshots.aggregateFactories
- an array of AggregateFactory
instances which this snapshotter will supportpublic AggregateSnapshotter.Builder aggregateFactories(List<AggregateFactory<?>> aggregateFactories)
aggregateFactories
supported by this snapshotter. The AggregateFactory
instances are
used to create the relevant Aggregate Root instance, which represent the snapshots.aggregateFactories
- a List
of AggregateFactory
instances which this snapshotter will
supportpublic AggregateSnapshotter.Builder repositoryProvider(RepositoryProvider repositoryProvider)
RepositoryProvider
provided to the snapshot aggregates this snapshotter creates for correct
instantiation.repositoryProvider
- the RepositoryProvider
provided to the snapshot aggregates this snapshotter
creates for correct instantiationpublic AggregateSnapshotter.Builder parameterResolverFactory(ParameterResolverFactory parameterResolverFactory)
ParameterResolverFactory
used to resolve parameter values for annotated handlers in the
snapshot aggregate this snapshotter creates.parameterResolverFactory
- the ParameterResolverFactory
used to resolve parameter values for
annotated handlers in the snapshot aggregate this snapshotter createspublic AggregateSnapshotter.Builder handlerDefinition(HandlerDefinition handlerDefinition)
HandlerDefinition
used to create concrete handlers in the snapshot aggregate this
snapshotter creates.handlerDefinition
- the HandlerDefinition
used to create concrete handlers in the snapshot
aggregate this snapshotter createspublic AggregateSnapshotter build()
AggregateSnapshotter
as specified through this Builder.AggregateSnapshotter
as specified through this Builderprotected ParameterResolverFactory buildParameterResolverFactory()
ParameterResolverFactory
, or create and return it if it is null
. In case it
has not been set yet, a ParameterResolverFactory is created by calling the
ClasspathParameterResolverFactory.forClass(Class)
function, either providing the
AggregateSnapshotter
type or the first AggregateFactory
it's class as input.
Note: it is recommended to use this function when retrieving the ParameterResolverFactory as it ensure it is non null.
ParameterResolverFactory
protected HandlerDefinition buildHandlerDefinition()
HandlerDefinition
, or create and return it if it is null
. In case it
has not been set yet, a HandlerDefinition is created by calling the
ClasspathHandlerDefinition.forClass(Class)
function, either providing the
AggregateSnapshotter
type or the first AggregateFactory
it's class as input.
Note: it is recommended to use this function when retrieving the HandlerDefinition as it ensure it is non null.
ParameterResolverFactory
protected void validate() throws AxonConfigurationException
validate
in class AbstractSnapshotter.Builder
AxonConfigurationException
- if one field is asserted to be incorrect according to the Builder's
specificationsCopyright © 2010–2022. All rights reserved.