AggregateTypeConfiguration

data class AggregateTypeConfiguration(val aggregateType: AggregateType, val aggregateIdType: Class<*>, val aggregateIdSerializer: AggregateIdSerializer, val deciderSupportsAggregateTypeChecker: DeciderSupportsAggregateTypeChecker, val commandAggregateIdResolver: CommandAggregateIdResolver, val eventAggregateIdResolver: EventAggregateIdResolver)

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

aggregateType

The AggregateType that is being configured

aggregateIdType

The Aggregate-Id type that is used in commands and events relating to the AggregateType

aggregateIdSerializer

The AggregateIdSerializer capable of serializing/deserializing the AggregateType-Id

deciderSupportsAggregateTypeChecker

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

commandAggregateIdResolver
  • A CommandAggregateIdResolver which can resolve the optional Aggregate-Id value from an instance of a Command compatible with this AggregateType

eventAggregateIdResolver
  • A EventAggregateIdResolver which can resolve the required Aggregate-Id value from an instance of an Event compatible with this AggregateType

Constructors

Link copied to clipboard
constructor(aggregateType: AggregateType, aggregateIdType: Class<*>, aggregateIdSerializer: AggregateIdSerializer, deciderSupportsAggregateTypeChecker: DeciderSupportsAggregateTypeChecker, commandAggregateIdResolver: CommandAggregateIdResolver, eventAggregateIdResolver: EventAggregateIdResolver)

Properties