Class AbstractRepository.Builder<T>
java.lang.Object
org.axonframework.modelling.command.AbstractRepository.Builder<T>
- Type Parameters:
T- a generic specifying the Aggregate type contained in thisRepositoryimplementation
- Direct Known Subclasses:
LockingRepository.Builder
- Enclosing class:
AbstractRepository<T,A extends Aggregate<T>>
Abstract Builder class to instantiate
AbstractRepository implementations.
This Builder's main goal is to build an AggregateModel specifying generic T as the aggregate type
to be stored. All aggregates in this repository must be instanceOf this aggregate type. To instantiate
this AggregateModel, either an AggregateModel can be provided directly or an aggregateType of
type Class can be used. The latter will internally resolve to an AggregateModel. Thus, either the
AggregateModel or the aggregateType should be provided.
The SpanFactory defaults to a NoOpSpanFactory.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaggregateModel(AggregateModel<T> aggregateModel) Sets theAggregateModelof generic typeT, describing the structure of the aggregate thisRepositorywill store.protected AggregateModel<T> Instantiate theAggregateModelof generic typeTdescribing the structure of the Aggregate thisRepositorywill store.handlerDefinition(HandlerDefinition handlerDefinition) Sets theHandlerDefinitionused to create concrete handlers for the givenaggregateType.parameterResolverFactory(ParameterResolverFactory parameterResolverFactory) Sets theParameterResolverFactoryused to resolve parameters for annotated handlers contained in the Aggregate.spanFactory(RepositorySpanFactory spanFactory) Sets theRepositorySpanFactoryimplementation to use for providing tracing capabilities.spanFactory(SpanFactory spanFactory) Deprecated.Sets a subtype of theaggregate typerepresented by thisRepository.Sets the subtypes of theaggregate typerepresented by thisRepository.protected voidvalidate()Validates whether the fields contained in this Builder are set accordingly.
-
Field Details
-
aggregateType
-
subtypes
-
-
Constructor Details
-
Builder
Creates a builder for a Repository for givenaggregateType.- Parameters:
aggregateType- theaggregateTypespecifying the type of aggregate thisRepositorywill store
-
-
Method Details
-
parameterResolverFactory
public AbstractRepository.Builder<T> parameterResolverFactory(@Nonnull ParameterResolverFactory parameterResolverFactory) Sets theParameterResolverFactoryused to resolve parameters for annotated handlers contained in the Aggregate. Only used if theaggregateTypeapproach is selected to create anAggregateModel.- Parameters:
parameterResolverFactory- aParameterResolverFactoryused to resolve parameters for annotated handlers contained in the Aggregate- Returns:
- the current Builder instance, for fluent interfacing
-
handlerDefinition
public AbstractRepository.Builder<T> handlerDefinition(@Nonnull HandlerDefinition handlerDefinition) Sets theHandlerDefinitionused to create concrete handlers for the givenaggregateType. Only used if theaggregateTypeapproach is selected to create anAggregateModel.- Parameters:
handlerDefinition- aHandlerDefinitionused to create concrete handlers for the givenaggregateType.- Returns:
- the current Builder instance, for fluent interfacing
-
aggregateModel
Sets theAggregateModelof generic typeT, describing the structure of the aggregate thisRepositorywill store.- Parameters:
aggregateModel- theAggregateModelof generic typeTof the aggregate thisRepositorywill store- Returns:
- the current Builder instance, for fluent interfacing
-
subtypes
Sets the subtypes of theaggregate typerepresented by thisRepository. Defining subtypes indicates thisRepositorysupports polymorphic aggregate structure.Only used if the
aggregate modelis not explicitly set. Defaults to an emptySet.- Parameters:
subtypes- The subtypes of theaggregate typerepresented by thisRepository.- Returns:
- The current Builder instance, for fluent interfacing.
-
subtype
Sets a subtype of theaggregate typerepresented by thisRepository. Defining a subtype indicates thisRepositorysupports a polymorphic aggregate structure.Only used if the
aggregate modelis not explicitly set.- Parameters:
subtype- A subtypes of theaggregate typerepresented by thisRepository.- Returns:
- The current Builder instance, for fluent interfacing.
-
spanFactory
Deprecated.UsespanFactory(RepositorySpanFactory)instead, as it provides more configuration optionsSets theSpanFactoryimplementation to use for providing tracing capabilities. Defaults to aNoOpSpanFactoryby default, which provides no tracing capabilities.- Parameters:
spanFactory- TheSpanFactoryimplementation- Returns:
- The current Builder instance, for fluent interfacing.
-
spanFactory
Sets theRepositorySpanFactoryimplementation to use for providing tracing capabilities. Defaults to aDefaultRepositorySpanFactorybacked by aNoOpSpanFactory, which provides no tracing capabilities.- Parameters:
spanFactory- TheSpanFactoryimplementation- Returns:
- The current Builder instance, for fluent interfacing.
-
buildAggregateModel
Instantiate theAggregateModelof generic typeTdescribing the structure of the Aggregate thisRepositorywill store.- Returns:
- a
AggregateModelof generic typeTdescribing the Aggregate thisRepositorywill store
-
validate
Validates whether the fields contained in this Builder are set accordingly.- Throws:
AxonConfigurationException- if one field is asserted to be incorrect according to the Builder's specifications
-
spanFactory(RepositorySpanFactory)instead, as it provides more configuration options