A
- the type of Aggregate configuredpublic class AggregateConfigurer<A> extends Object implements AggregateConfiguration<A>
Modifier | Constructor and Description |
---|---|
protected |
AggregateConfigurer(Class<A> aggregate)
Creates a default configuration as described in
defaultConfiguration(Class) . |
Modifier and Type | Method and Description |
---|---|
AggregateFactory<A> |
aggregateFactory()
Returns the
AggregateFactory defined in this configuration. |
Class<A> |
aggregateType()
Returns the type of Aggregate defined in this configuration.
|
AggregateConfigurer<A> |
configureAggregateFactory(Function<Configuration,AggregateFactory<A>> aggregateFactoryBuilder)
Defines the factory to use to create new Aggregates instances of the type under configuration.
|
AggregateConfigurer<A> |
configureCache(Function<Configuration,Cache> cache)
Configures the Cache to use for the repository created for this Aggregate type.
|
AggregateConfigurer<A> |
configureCommandHandler(Function<Configuration,AggregateAnnotationCommandHandler<A>> aggregateCommandHandlerBuilder)
Defines the AggregateAnnotationCommandHandler instance to use.
|
AggregateConfigurer<A> |
configureCommandTargetResolver(Function<Configuration,CommandTargetResolver> commandTargetResolverBuilder)
Defines the CommandTargetResolver to use for the Aggregate type under configuration.
|
AggregateConfigurer<A> |
configureCreationPolicyAggregateFactory(Function<Configuration,CreationPolicyAggregateFactory<A>> creationPolicyAggregateFactoryBuilder)
Defines the factory to create new aggregate instances of the type under configuration when initializing those
instances from non-constructor command handlers annotated with
CreationPolicy . |
AggregateConfigurer<A> |
configureEventStreamFilter(Function<Configuration,Predicate<? super DomainEventMessage<?>>> filterBuilder)
Configures an event stream filter for the EventSourcingRepository for the Aggregate type under configuration.
|
AggregateConfigurer<A> |
configureFilterEventsByType(Function<Configuration,Boolean> filterConfigurationPredicate)
Configures a function that determines whether or not the EventSourcingRepository for the Aggregate type under
configuration should filter out events with non-matching types.
|
AggregateConfigurer<A> |
configureLockFactory(Function<Configuration,LockFactory> lockFactory)
Defines the
LockFactory to use in the Repository for the aggregate under configuration. |
AggregateConfigurer<A> |
configureRepository(Function<Configuration,Repository<A>> repositoryBuilder)
Defines the repository to use to load and store Aggregates of this type.
|
AggregateConfigurer<A> |
configureSnapshotFilter(Function<Configuration,SnapshotFilter> snapshotFilter)
Configure a
SnapshotFilter for the Aggregate type under configuration. |
AggregateConfigurer<A> |
configureSnapshotTrigger(Function<Configuration,SnapshotTriggerDefinition> snapshotTriggerDefinition)
Configures snapshotting for the Aggregate type under configuration.
|
AggregateConfigurer<A> |
configureWeakReferenceCache()
Configures a WeakReferenceCache to be used for the repository created for this Aggregate type.
|
CreationPolicyAggregateFactory<A> |
creationPolicyAggregateFactory()
Returns the
CreationPolicyAggregateFactory defined in this configuration. |
static <A> AggregateConfigurer<A> |
defaultConfiguration(Class<A> aggregateType)
Creates a default Configuration for an aggregate of the given
aggregateType . |
void |
initialize(Configuration config)
Initialize the module configuration using the given global
config . |
static <A> AggregateConfigurer<A> |
jpaMappedConfiguration(Class<A> aggregateType)
Creates a Configuration for an aggregate of given
aggregateType , which is mapped to a relational database
using an EntityManager obtained from the main configuration. |
static <A> AggregateConfigurer<A> |
jpaMappedConfiguration(Class<A> aggregateType,
EntityManagerProvider entityManagerProvider)
Creates a Configuration for an aggregate of given
aggregateType , which is mapped to a relational database
using an EntityManager provided by given entityManagerProvider . |
Repository<A> |
repository()
Returns the repository defined to load instances of the Aggregate type defined in this configuration.
|
SnapshotFilter |
snapshotFilter()
Returns the
SnapshotFilter defined in this configuration. |
AggregateConfigurer<A> |
withSubtypes(Class<? extends A>... subtypes)
Registers subtypes of this aggregate to support aggregate polymorphism.
|
AggregateConfigurer<A> |
withSubtypes(Collection<Class<? extends A>> subtypes)
Registers subtypes of this aggregate to support aggregate polymorphism.
|
protected AggregateConfigurer(Class<A> aggregate)
defaultConfiguration(Class)
. This constructor is
available for subclasses that provide additional configuration possibilities.aggregate
- The type of aggregate to configurepublic static <A> AggregateConfigurer<A> defaultConfiguration(Class<A> aggregateType)
aggregateType
. This required either a
Repository to be configured using configureRepository(Function)
, or that the Global Configuration
contains an Event Store and the Aggregate support Event Sourcing.A
- The type of Aggregate to configureaggregateType
- The type of Aggregate to configurepublic static <A> AggregateConfigurer<A> jpaMappedConfiguration(Class<A> aggregateType)
aggregateType
, which is mapped to a relational database
using an EntityManager obtained from the main configuration. The given aggregateType
is expected to be a
proper JPA Entity.
The EntityManagerProvider is expected to have been registered with the Configurer (which would be the case when
using DefaultConfigurer.jpaConfiguration(EntityManagerProvider)
. If that is not the case, consider using
jpaMappedConfiguration(Class, EntityManagerProvider)
instead.
A
- The type of Aggregate to configureaggregateType
- The type of Aggregate to configurepublic static <A> AggregateConfigurer<A> jpaMappedConfiguration(Class<A> aggregateType, EntityManagerProvider entityManagerProvider)
aggregateType
, which is mapped to a relational database
using an EntityManager provided by given entityManagerProvider
. The given aggregateType
is
expected to be a proper JPA Entity.A
- The type of Aggregate to configureaggregateType
- The type of Aggregate to configureentityManagerProvider
- The provider for Axon to retrieve the EntityManager frompublic AggregateConfigurer<A> configureRepository(Function<Configuration,Repository<A>> repositoryBuilder)
repositoryBuilder
- The builder function for the repositorypublic AggregateConfigurer<A> configureAggregateFactory(Function<Configuration,AggregateFactory<A>> aggregateFactoryBuilder)
aggregateFactoryBuilder
- The builder function for the AggregateFactorypublic AggregateConfigurer<A> configureCreationPolicyAggregateFactory(Function<Configuration,CreationPolicyAggregateFactory<A>> creationPolicyAggregateFactoryBuilder)
CreationPolicy
.
When subtypes
are provided, the given CreationPolicyAggregateFactory
is
used for every implementation of the aggregate under construction.
creationPolicyAggregateFactoryBuilder
- The builder function for the
CreationPolicyAggregateFactory
.public AggregateConfigurer<A> configureLockFactory(Function<Configuration,LockFactory> lockFactory)
LockFactory
to use in the Repository
for the aggregate under configuration. Defaults
to the PessimisticLockFactory
for the EventSourcingRepository
and NullLockFactory
for a
GenericJpaRepository
.lockFactory
- a Function
building the LockFactory
to use based on the Configuration
public AggregateConfigurer<A> configureCommandHandler(Function<Configuration,AggregateAnnotationCommandHandler<A>> aggregateCommandHandlerBuilder)
aggregateCommandHandlerBuilder
- The builder function for the AggregateCommandHandlerpublic AggregateConfigurer<A> configureCommandTargetResolver(Function<Configuration,CommandTargetResolver> commandTargetResolverBuilder)
commandTargetResolverBuilder
- the builder function for the CommandTargetResolver.public AggregateConfigurer<A> configureSnapshotTrigger(Function<Configuration,SnapshotTriggerDefinition> snapshotTriggerDefinition)
Note that this configuration is ignored if a custom repository instance is configured.
snapshotTriggerDefinition
- The function creating the SnapshotTriggerDefinitionpublic AggregateConfigurer<A> configureSnapshotFilter(Function<Configuration,SnapshotFilter> snapshotFilter)
SnapshotFilter
for the Aggregate type under configuration. Note that SnapshotFilter
instances will be combined and should return true
if they handle a snapshot they wish to ignore.snapshotFilter
- the function creating the SnapshotFilter
public AggregateConfigurer<A> configureEventStreamFilter(Function<Configuration,Predicate<? super DomainEventMessage<?>>> filterBuilder)
Note that this configuration is ignored if a custom repository instance is configured.
filterBuilder
- The function creating the filter.EventSourcingRepository.Builder#eventStreamFilter(Predicate)
public AggregateConfigurer<A> configureCache(Function<Configuration,Cache> cache)
configureRepository(Function)
.cache
- the function that defines the Cache to usepublic AggregateConfigurer<A> configureWeakReferenceCache()
configureRepository(Function)
.public AggregateConfigurer<A> configureFilterEventsByType(Function<Configuration,Boolean> filterConfigurationPredicate)
Note that this configuration is ignored if a custom repository instance is configured, and that
configureEventStreamFilter(Function)
overrides this.
filterConfigurationPredicate
- The function determining whether or not to filter events by Aggregate type.EventSourcingRepository.Builder#filterByAggregateType()
public void initialize(Configuration config)
ModuleConfiguration
config
. Any specific start up or shut down
processes should be added here by using the provided config
and invoke LifecycleOperations.onStart(int,
LifecycleHandler)
and LifecycleOperations.onShutdown(int, LifecycleHandler)
respectively.initialize
in interface ModuleConfiguration
config
- the global configuration, providing access to generic componentspublic Repository<A> repository()
AggregateConfiguration
repository
in interface AggregateConfiguration<A>
public Class<A> aggregateType()
AggregateConfiguration
aggregateType
in interface AggregateConfiguration<A>
public AggregateFactory<A> aggregateFactory()
AggregateConfiguration
AggregateFactory
defined in this configuration.aggregateFactory
in interface AggregateConfiguration<A>
AggregateFactory
defined in this configuration.public SnapshotFilter snapshotFilter()
AggregateConfiguration
SnapshotFilter
defined in this configuration.snapshotFilter
in interface AggregateConfiguration<A>
SnapshotFilter
defined in this configuration@SafeVarargs public final AggregateConfigurer<A> withSubtypes(Class<? extends A>... subtypes)
subtypes
- subtypes in this polymorphic hierarchypublic AggregateConfigurer<A> withSubtypes(Collection<Class<? extends A>> subtypes)
subtypes
- subtypes in this polymorphic hierarchypublic CreationPolicyAggregateFactory<A> creationPolicyAggregateFactory()
CreationPolicyAggregateFactory
defined in this configuration.CreationPolicyAggregateFactory
defined in this configuration.Copyright © 2010–2024. All rights reserved.