T
- a generic specifying the Aggregate type contained in this Repository
implementationpublic static class GenericJpaRepository.Builder<T> extends LockingRepository.Builder<T>
GenericJpaRepository
for aggregate type T
.
The LockFactory
is defaulted to an NullLockFactory
, thus providing no additional locking, and
the identifierConverter
to Function.identity()
. The SpanFactory
is defaulted to a
NoOpSpanFactory
.
A goal of this Builder goal is to create 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.
Additionally, the EntityManagerProvider
and EventBus
are hard requirements and as such
should be provided.
aggregateType, subtypes
Modifier | Constructor and Description |
---|---|
protected |
Builder(Class<T> aggregateType)
Creates a builder for a Repository for given
aggregateType . |
Modifier and Type | Method and Description |
---|---|
GenericJpaRepository.Builder<T> |
aggregateModel(AggregateModel<T> aggregateModel)
Sets the
AggregateModel of generic type T , describing the structure of the aggregate this
Repository will store. |
GenericJpaRepository<T> |
build()
Initializes a
GenericJpaRepository as specified through this Builder. |
GenericJpaRepository.Builder<T> |
entityManagerProvider(EntityManagerProvider entityManagerProvider)
Sets the
EntityManagerProvider which provides the EntityManager instance for this
repository. |
GenericJpaRepository.Builder<T> |
eventBus(EventBus eventBus)
Sets the
EventBus to which events are published. |
GenericJpaRepository.Builder<T> |
handlerDefinition(HandlerDefinition handlerDefinition)
Sets the
HandlerDefinition used to create concrete handlers for the given aggregateType . |
GenericJpaRepository.Builder<T> |
identifierConverter(Function<String,?> identifierConverter)
|
GenericJpaRepository.Builder<T> |
lockFactory(LockFactory lockFactory)
Sets the
LockFactory used to lock an aggregate. |
GenericJpaRepository.Builder<T> |
parameterResolverFactory(ParameterResolverFactory parameterResolverFactory)
Sets the
ParameterResolverFactory used to resolve parameters for annotated handlers contained in the
Aggregate. |
GenericJpaRepository.Builder<T> |
repositoryProvider(RepositoryProvider repositoryProvider)
Sets the
RepositoryProvider which services repositories for specific aggregate types. |
GenericJpaRepository.Builder<T> |
spanFactory(SpanFactory spanFactory)
Sets the
SpanFactory implementation to use for providing tracing capabilities. |
GenericJpaRepository.Builder<T> |
subtype(Class<? extends T> subtype)
Sets a subtype of the
aggregate type represented by this Repository . |
GenericJpaRepository.Builder<T> |
subtypes(Set<Class<? extends T>> subtypes)
Sets the subtypes of the
aggregate type represented by this Repository . |
protected void |
validate()
Validates whether the fields contained in this Builder are set accordingly.
|
buildAggregateModel
protected Builder(Class<T> aggregateType)
aggregateType
.aggregateType
- the aggregateType
specifying the type of aggregate this Repository
will
storepublic GenericJpaRepository.Builder<T> parameterResolverFactory(@Nonnull ParameterResolverFactory parameterResolverFactory)
AbstractRepository.Builder
ParameterResolverFactory
used to resolve parameters for annotated handlers contained in the
Aggregate. Only used if the aggregateType
approach is selected to create an AggregateModel
.parameterResolverFactory
in class LockingRepository.Builder<T>
parameterResolverFactory
- a ParameterResolverFactory
used to resolve parameters for annotated
handlers contained in the Aggregatepublic GenericJpaRepository.Builder<T> handlerDefinition(@Nonnull HandlerDefinition handlerDefinition)
AbstractRepository.Builder
HandlerDefinition
used to create concrete handlers for the given aggregateType
. Only
used if the aggregateType
approach is selected to create an AggregateModel
.handlerDefinition
in class LockingRepository.Builder<T>
handlerDefinition
- a HandlerDefinition
used to create concrete handlers for the given aggregateType
.public GenericJpaRepository.Builder<T> aggregateModel(@Nonnull AggregateModel<T> aggregateModel)
AbstractRepository.Builder
AggregateModel
of generic type T
, describing the structure of the aggregate this
Repository
will store.aggregateModel
in class LockingRepository.Builder<T>
aggregateModel
- the AggregateModel
of generic type T
of the aggregate this Repository
will storepublic GenericJpaRepository.Builder<T> lockFactory(LockFactory lockFactory)
LockingRepository.Builder
LockFactory
used to lock an aggregate. Defaults to a pessimistic locking strategy,
implemented in the PessimisticLockFactory
.lockFactory
in class LockingRepository.Builder<T>
lockFactory
- a LockFactory
used to lock an aggregatepublic GenericJpaRepository.Builder<T> subtypes(@Nonnull Set<Class<? extends T>> subtypes)
AbstractRepository.Builder
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
.
subtypes
in class LockingRepository.Builder<T>
subtypes
- The subtypes of the aggregate type
represented by this
Repository
.public GenericJpaRepository.Builder<T> subtype(@Nonnull Class<? extends T> subtype)
AbstractRepository.Builder
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.
subtype
in class LockingRepository.Builder<T>
subtype
- A subtypes of the aggregate type
represented by this
Repository
.public GenericJpaRepository.Builder<T> spanFactory(SpanFactory spanFactory)
AbstractRepository.Builder
SpanFactory
implementation to use for providing tracing capabilities. Defaults to a
NoOpSpanFactory
by default, which provides no tracing capabilities.spanFactory
in class LockingRepository.Builder<T>
spanFactory
- The SpanFactory
implementationpublic GenericJpaRepository.Builder<T> entityManagerProvider(EntityManagerProvider entityManagerProvider)
EntityManagerProvider
which provides the EntityManager
instance for this
repository.entityManagerProvider
- a EntityManagerProvider
which provides the EntityManager
instance for this repositorypublic GenericJpaRepository.Builder<T> eventBus(EventBus eventBus)
EventBus
to which events are published.eventBus
- an EventBus
to which events are publishedpublic GenericJpaRepository.Builder<T> repositoryProvider(RepositoryProvider repositoryProvider)
RepositoryProvider
which services repositories for specific aggregate types.repositoryProvider
- a RepositoryProvider
servicing repositories for specific aggregate typespublic GenericJpaRepository.Builder<T> identifierConverter(Function<String,?> identifierConverter)
public GenericJpaRepository<T> build()
GenericJpaRepository
as specified through this Builder.GenericJpaRepository
as specified through this Builderprotected void validate()
AbstractRepository.Builder
validate
in class AbstractRepository.Builder<T>
Copyright © 2010–2023. All rights reserved.