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()
.
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
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. |
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(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(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(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> 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–2020. All rights reserved.