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 this Repository implementation
Direct Known Subclasses:
LockingRepository.Builder
Enclosing class:
AbstractRepository<T,A extends Aggregate<T>>

public abstract static class AbstractRepository.Builder<T> extends Object
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 Details

    • aggregateType

      protected final Class<T> aggregateType
    • subtypes

      protected Set<Class<? extends T>> subtypes
  • Constructor Details

    • Builder

      protected Builder(Class<T> aggregateType)
      Creates a builder for a Repository for given aggregateType.
      Parameters:
      aggregateType - the aggregateType specifying the type of aggregate this Repository will store
  • Method Details

    • parameterResolverFactory

      public AbstractRepository.Builder<T> parameterResolverFactory(@Nonnull org.axonframework.messaging.annotation.ParameterResolverFactory parameterResolverFactory)
      Sets the ParameterResolverFactory used to resolve parameters for annotated handlers contained in the Aggregate. Only used if the aggregateType approach is selected to create an AggregateModel.
      Parameters:
      parameterResolverFactory - a ParameterResolverFactory used 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 org.axonframework.messaging.annotation.HandlerDefinition handlerDefinition)
      Sets the HandlerDefinition used to create concrete handlers for the given aggregateType. Only used if the aggregateType approach is selected to create an AggregateModel.
      Parameters:
      handlerDefinition - a HandlerDefinition used to create concrete handlers for the given aggregateType.
      Returns:
      the current Builder instance, for fluent interfacing
    • aggregateModel

      public AbstractRepository.Builder<T> aggregateModel(@Nonnull AggregateModel<T> aggregateModel)
      Sets the AggregateModel of generic type T, describing the structure of the aggregate this Repository will store.
      Parameters:
      aggregateModel - the AggregateModel of generic type T of the aggregate this Repository will store
      Returns:
      the current Builder instance, for fluent interfacing
    • subtypes

      public AbstractRepository.Builder<T> subtypes(@Nonnull Set<Class<? extends T>> subtypes)
      Sets the subtypes of the aggregate type represented by this Repository. Defining subtypes indicates this Repository supports polymorphic aggregate structure.

      Only used if the aggregate model is not explicitly set. Defaults to an empty Set.

      Parameters:
      subtypes - The subtypes of the aggregate type represented by this Repository.
      Returns:
      The current Builder instance, for fluent interfacing.
    • subtype

      public AbstractRepository.Builder<T> subtype(@Nonnull Class<? extends T> subtype)
      Sets a subtype of the aggregate type represented by this Repository. Defining a subtype indicates this Repository supports a polymorphic aggregate structure.

      Only used if the aggregate model is not explicitly set.

      Parameters:
      subtype - A subtypes of the aggregate type represented by this Repository.
      Returns:
      The current Builder instance, for fluent interfacing.
    • spanFactory

      @Deprecated public AbstractRepository.Builder<T> spanFactory(org.axonframework.tracing.SpanFactory spanFactory)
      Deprecated.
      Use spanFactory(RepositorySpanFactory) instead, as it provides more configuration options
      Sets the SpanFactory implementation to use for providing tracing capabilities. Defaults to a NoOpSpanFactory by default, which provides no tracing capabilities.
      Parameters:
      spanFactory - The SpanFactory implementation
      Returns:
      The current Builder instance, for fluent interfacing.
    • spanFactory

      public AbstractRepository.Builder<T> spanFactory(RepositorySpanFactory spanFactory)
      Sets the RepositorySpanFactory implementation to use for providing tracing capabilities. Defaults to a DefaultRepositorySpanFactory backed by a NoOpSpanFactory, which provides no tracing capabilities.
      Parameters:
      spanFactory - The SpanFactory implementation
      Returns:
      The current Builder instance, for fluent interfacing.
    • buildAggregateModel

      protected AggregateModel<T> buildAggregateModel()
      Instantiate the AggregateModel of generic type T describing the structure of the Aggregate this Repository will store.
      Returns:
      a AggregateModel of generic type T describing the Aggregate this Repository will store
    • validate

      protected void validate() throws org.axonframework.common.AxonConfigurationException
      Validates whether the fields contained in this Builder are set accordingly.
      Throws:
      org.axonframework.common.AxonConfigurationException - if one field is asserted to be incorrect according to the Builder's specifications