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 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> |
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> |
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.
|
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> 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 Configuration.onStart(int,
LifecycleHandler)
and Configuration.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 hierarchyCopyright © 2010–2022. All rights reserved.