Aggregate Type Configuration
AggregateType configuration which defines how the dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore should be configured in order to support event-streams for the specified aggregateType
If you register your AggregateTypeConfiguration in Spring as a Bean and combine it with DeciderSupportsAggregateTypeChecker then AggregateType's are automatically registered with the dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.EventStore
Example:
@Configuration
class OrdersConfiguration {
companion object {
@JvmStatic
val AGGREGATE_TYPE = AggregateType.of("Orders")
}
@Bean
fun orderAggregateTypeConfiguration(): AggregateTypeConfiguration {
return AggregateTypeConfiguration(AGGREGATE_TYPE,
OrderId::class.java,
AggregateIdSerializer.serializerFor(OrderId::class.java),
DeciderSupportsAggregateTypeChecker.HandlesCommandsThatInheritsFromCommandType(OrderCommand::class),
commandAggregateIdResolver = { cmd -> (cmd as OrderCommand).id },
eventAggregateIdResolver = { e -> (e as OrderEvent).id })
}
}Parameters
The AggregateType that is being configured
The Aggregate-Id type that is used in commands and events relating to the AggregateType
The AggregateIdSerializer capable of serializing/deserializing the AggregateType-Id
A DeciderSupportsAggregateTypeChecker instance which given a concrete Decider instance is capable of determining if the given Decider instance is working with the AggregateType configured in this AggregateTypeConfiguration - see DeciderSupportsAggregateTypeChecker.HandlesCommandsThatInheritsFromCommandType
A CommandAggregateIdResolver which can resolve the optional Aggregate-Id value from an instance of a Command compatible with this AggregateType
A EventAggregateIdResolver which can resolve the required Aggregate-Id value from an instance of an Event compatible with this AggregateType