Interface StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>
-
- Type Parameters:
ID- the aggregate id type (aka stream-id)EVENT_TYPE- the type of eventAGGREGATE_IMPL_TYPE- the aggregate implementation type
- All Known Implementing Classes:
StatefulAggregateRepository.DefaultStatefulAggregateRepository
public interface StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>OpinionatedAggregateRepository that's built to persist and load a specificStatefulAggregatetype in combination withEventStore,UnitOfWorkFactoryand aStatefulAggregateInstanceFactory.
You can use thefrom(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class)to create a newStatefulAggregateRepositoryinstance that supports the most common repository method.
Alternatively you can extend from theStatefulAggregateRepository.DefaultStatefulAggregateRepositoryand add your own special methods
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classStatefulAggregateRepository.DefaultStatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>DefaultStatefulAggregateRepositoryimplementation.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description Class<ID>aggregateIdType()The type of aggregate ID this repository usesClass<AGGREGATE_IMPL_TYPE>aggregateRootImplementationType()The type ofStatefulAggregateimplementation this repository handlesdk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateTypeaggregateType()The type ofAggregateTypethis repository is using to persist Eventsstatic <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>
StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>from(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, CONFIG eventStreamConfiguration, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType)Create anStatefulAggregateRepositoryinstance that supports loading and persisting the given Aggregate type - theEventStorewill be configured with the suppliedeventStreamConfiguration.
This factory method will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
If that fails please usefrom(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>
StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>from(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, CONFIG eventStreamConfiguration, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType, AggregateSnapshotRepository aggregateSnapshotRepository)Create anStatefulAggregateRepositoryinstance that supports loading and persisting the given Aggregate type - theEventStorewill be configured with the suppliedeventStreamConfiguration.
This factory method will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
If that fails please usefrom(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>
StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>from(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, CONFIG eventStreamConfiguration, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<ID> aggregateIdType, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType)Create anStatefulAggregateRepositoryinstance that supports loading and persisting the given Aggregate type - theEventStorewill be configured with the suppliedeventStreamConfigurationstatic <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>
StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>from(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, CONFIG eventStreamConfiguration, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<ID> aggregateIdType, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType, AggregateSnapshotRepository aggregateSnapshotRepository)Create anStatefulAggregateRepositoryinstance that supports loading and persisting the given Aggregate type - theEventStorewill be configured with the suppliedeventStreamConfigurationstatic <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>
StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>from(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType)Create anStatefulAggregateRepositoryinstance that supports loading and persisting the given Aggregate type - if missing, theEventStorewill be configured with the defaultAggregateEventStreamConfigurationbased on theAggregateEventStreamConfigurationFactorythat theEventStore'sAggregateEventStreamPersistenceStrategyis configured with
This factory method will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
If that fails please usefrom(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>
StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>from(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType, AggregateSnapshotRepository aggregateSnapshotRepository)Create anStatefulAggregateRepositoryinstance that supports loading and persisting the given Aggregate type - if missing, theEventStorewill be configured with the defaultAggregateEventStreamConfigurationbased on theAggregateEventStreamConfigurationFactorythat theEventStore'sAggregateEventStreamPersistenceStrategyis configured with
This factory method will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
If that fails please usefrom(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>
StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>from(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<ID> aggregateIdType, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType)Create anStatefulAggregateRepositoryinstance that supports loading and persisting the given Aggregate type - if missing, theEventStorewill be configured with the defaultAggregateEventStreamConfigurationbased on theAggregateEventStreamConfigurationFactorythat theEventStore'sAggregateEventStreamPersistenceStrategyis configured withstatic <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>
StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>from(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<ID> aggregateIdType, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType, AggregateSnapshotRepository aggregateSnapshotRepository)Create anStatefulAggregateRepositoryinstance that supports loading and persisting the given Aggregate type - if missing, theEventStorewill be configured with the defaultAggregateEventStreamConfigurationbased on theAggregateEventStreamConfigurationFactorythat theEventStore'sAggregateEventStreamPersistenceStrategyis configured withdefault AGGREGATE_IMPL_TYPEload(ID aggregateId)Load anStatefulAggregateinstance with the specifiedaggregateIdfrom the underlyingEventStore
The loaded aggregate instance will be associated with theUnitOfWorkFactory.getRequiredUnitOfWork()and any changes to will be tracked and will be persisted to the underlyingEventStorewhen theUnitOfWorkis committed.default AGGREGATE_IMPL_TYPEload(ID aggregateId, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder expectedLatestEventOrder)Load anStatefulAggregateinstance with the specifiedaggregateIdfrom the underlyingEventStore
The loaded aggregate instance will be associated with theUnitOfWorkFactory.getRequiredUnitOfWork()and any changes to will be tracked and will be persisted to the underlyingEventStorewhen theUnitOfWorkis committed.default voidpersist(AGGREGATE_IMPL_TYPE aggregate)Deprecated.Usesave(StatefulAggregate)insteadAGGREGATE_IMPL_TYPEsave(AGGREGATE_IMPL_TYPE aggregate)Save/Associate a newly created and not yet persistedStatefulAggregateinstance with theUnitOfWorkFactory.getRequiredUnitOfWork()
Any changes to will be tracked and will be persisted to the underlyingEventStorewhen theUnitOfWorkis committed.default Optional<AGGREGATE_IMPL_TYPE>tryLoad(ID aggregateId)Try to load anStatefulAggregateinstance with the specifiedaggregateIdfrom the underlyingEventStore
If the aggregate instance exists it will be associated with theUnitOfWorkFactory.getRequiredUnitOfWork()and any changes to will be tracked and will be persisted to the underlyingEventStorewhen theUnitOfWorkis committed.default Optional<AGGREGATE_IMPL_TYPE>tryLoad(ID aggregateId, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder expectedLatestEventOrder)Try to load anStatefulAggregateinstance with the specifiedaggregateIdfrom the underlyingEventStore
If the aggregate instance exists it will be associated with theUnitOfWorkFactory.getRequiredUnitOfWork()and any changes to will be tracked and will be persisted to the underlyingEventStorewhen theUnitOfWorkis committed.Optional<AGGREGATE_IMPL_TYPE>tryLoad(ID aggregateId, Optional<dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder> expectedLatestEventOrder)Try to load anStatefulAggregateinstance with the specifiedaggregateIdfrom the underlyingEventStore
If the aggregate instance exists it will be associated with theUnitOfWorkFactory.getRequiredUnitOfWork()and any changes to will be tracked and will be persisted to the underlyingEventStorewhen theUnitOfWorkis committed.
-
-
-
Method Detail
-
from
static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>> StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE> from(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, CONFIG eventStreamConfiguration, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType)
Create anStatefulAggregateRepositoryinstance that supports loading and persisting the given Aggregate type - theEventStorewill be configured with the suppliedeventStreamConfiguration.
This factory method will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
If that fails please usefrom(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)- Type Parameters:
CONFIG- the aggregate type configurationID- the aggregate ID typeEVENT_TYPE- the type of eventAGGREGATE_IMPL_TYPE- the concrete aggregate type (MUST be a subtype ofStatefulAggregate)- Parameters:
eventStore- theEventStoreinstance to useeventStreamConfiguration- the configuration for the event stream that will contain all the events related to the aggregate typeaggregateRootInstanceFactory- the factory responsible for instantiating yourStatefulAggregate's when loading them from theEventStoreaggregateImplementationType- the concrete aggregate implementation type (MUST be a subtype ofStatefulAggregate).
It will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters- Returns:
- a repository instance that can be used load, add and query aggregates of type
aggregateType
-
from
static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>> StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE> from(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, CONFIG eventStreamConfiguration, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType, AggregateSnapshotRepository aggregateSnapshotRepository)
Create anStatefulAggregateRepositoryinstance that supports loading and persisting the given Aggregate type - theEventStorewill be configured with the suppliedeventStreamConfiguration.
This factory method will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
If that fails please usefrom(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)- Type Parameters:
CONFIG- the aggregate type configurationID- the aggregate ID typeEVENT_TYPE- the type of eventAGGREGATE_IMPL_TYPE- the concrete aggregate type (MUST be a subtype ofStatefulAggregate)- Parameters:
eventStore- theEventStoreinstance to useeventStreamConfiguration- the configuration for the event stream that will contain all the events related to the aggregate typeaggregateRootInstanceFactory- the factory responsible for instantiating yourStatefulAggregate's when loading them from theEventStoreaggregateImplementationType- the concrete aggregate implementation type (MUST be a subtype ofStatefulAggregate).
It will try to resolve the Aggregate Id type from the aggregateImplementationType type parametersaggregateSnapshotRepository- optional (may be null)AggregateSnapshotRepository- Returns:
- a repository instance that can be used load, add and query aggregates of type
aggregateType
-
from
static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>> StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE> from(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType)
Create anStatefulAggregateRepositoryinstance that supports loading and persisting the given Aggregate type - if missing, theEventStorewill be configured with the defaultAggregateEventStreamConfigurationbased on theAggregateEventStreamConfigurationFactorythat theEventStore'sAggregateEventStreamPersistenceStrategyis configured with
This factory method will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
If that fails please usefrom(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)- Type Parameters:
CONFIG- the aggregate type configurationID- the aggregate ID typeEVENT_TYPE- the type of eventAGGREGATE_IMPL_TYPE- the concrete aggregate type (MUST be a subtype ofStatefulAggregate)- Parameters:
eventStore- theEventStoreinstance to useaggregateType- the aggregate type being handled by this repositoryaggregateRootInstanceFactory- the factory responsible for instantiating yourStatefulAggregate's when loading them from theEventStoreaggregateImplementationType- the concrete aggregate implementation type (MUST be a subtype ofStatefulAggregate).
It will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters- Returns:
- a repository instance that can be used load, add and query aggregates of type
aggregateType
-
from
static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>> StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE> from(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType, AggregateSnapshotRepository aggregateSnapshotRepository)
Create anStatefulAggregateRepositoryinstance that supports loading and persisting the given Aggregate type - if missing, theEventStorewill be configured with the defaultAggregateEventStreamConfigurationbased on theAggregateEventStreamConfigurationFactorythat theEventStore'sAggregateEventStreamPersistenceStrategyis configured with
This factory method will try to resolve the Aggregate Id type from the aggregateImplementationType type parameters
If that fails please usefrom(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)- Type Parameters:
CONFIG- the aggregate type configurationID- the aggregate ID typeEVENT_TYPE- the type of eventAGGREGATE_IMPL_TYPE- the concrete aggregate type (MUST be a subtype ofStatefulAggregate)- Parameters:
eventStore- theEventStoreinstance to useaggregateType- the aggregate type being handled by this repositoryaggregateRootInstanceFactory- the factory responsible for instantiating yourStatefulAggregate's when loading them from theEventStoreaggregateImplementationType- the concrete aggregate implementation type (MUST be a subtype ofStatefulAggregate).
It will try to resolve the Aggregate Id type from the aggregateImplementationType type parametersaggregateSnapshotRepository- optional (may be null)AggregateSnapshotRepository- Returns:
- a repository instance that can be used load, add and query aggregates of type
aggregateType
-
from
static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>> StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE> from(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, CONFIG eventStreamConfiguration, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<ID> aggregateIdType, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType)
Create anStatefulAggregateRepositoryinstance that supports loading and persisting the given Aggregate type - theEventStorewill be configured with the suppliedeventStreamConfiguration- Type Parameters:
CONFIG- the aggregate type configurationID- the aggregate ID typeEVENT_TYPE- the type of eventAGGREGATE_IMPL_TYPE- the concrete aggregate type (MUST be a subtype ofStatefulAggregate)- Parameters:
eventStore- theEventStoreinstance to useeventStreamConfiguration- the configuration for the event stream that will contain all the events related to the aggregate typeaggregateRootInstanceFactory- the factory responsible for instantiating yourStatefulAggregate's when loading them from theEventStoreaggregateIdType- the concrete aggregate ID typeaggregateImplementationType- the concrete aggregate type (MUST be a subtype ofStatefulAggregate)- Returns:
- a repository instance that can be used load, add and query aggregates of type
aggregateType
-
from
static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>> StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE> from(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, CONFIG eventStreamConfiguration, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<ID> aggregateIdType, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType, AggregateSnapshotRepository aggregateSnapshotRepository)
Create anStatefulAggregateRepositoryinstance that supports loading and persisting the given Aggregate type - theEventStorewill be configured with the suppliedeventStreamConfiguration- Type Parameters:
CONFIG- the aggregate type configurationID- the aggregate ID typeEVENT_TYPE- the type of eventAGGREGATE_IMPL_TYPE- the concrete aggregate type (MUST be a subtype ofStatefulAggregate)- Parameters:
eventStore- theEventStoreinstance to useeventStreamConfiguration- the configuration for the event stream that will contain all the events related to the aggregate typeaggregateRootInstanceFactory- the factory responsible for instantiating yourStatefulAggregate's when loading them from theEventStoreaggregateIdType- the concrete aggregate ID typeaggregateImplementationType- the concrete aggregate type (MUST be a subtype ofStatefulAggregate)aggregateSnapshotRepository- optional (may be null)AggregateSnapshotRepository- Returns:
- a repository instance that can be used load, add and query aggregates of type
aggregateType
-
from
static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>> StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE> from(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<ID> aggregateIdType, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType)
Create anStatefulAggregateRepositoryinstance that supports loading and persisting the given Aggregate type - if missing, theEventStorewill be configured with the defaultAggregateEventStreamConfigurationbased on theAggregateEventStreamConfigurationFactorythat theEventStore'sAggregateEventStreamPersistenceStrategyis configured with- Type Parameters:
CONFIG- the aggregate type configurationID- the aggregate ID typeEVENT_TYPE- the type of eventAGGREGATE_IMPL_TYPE- the concrete aggregate type (MUST be a subtype ofStatefulAggregate)- Parameters:
eventStore- theEventStoreinstance to useaggregateType- the aggregate type being handled by this repositoryaggregateRootInstanceFactory- the factory responsible for instantiating yourStatefulAggregate's when loading them from theEventStoreaggregateIdType- the concrete aggregate ID typeaggregateImplementationType- the concrete aggregate type (MUST be a subtype ofStatefulAggregate)- Returns:
- a repository instance that can be used load, add and query aggregates of type
aggregateType
-
from
static <CONFIG extends dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.persistence.AggregateEventStreamConfiguration,ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>> StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE> from(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.ConfigurableEventStore<CONFIG> eventStore, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType, StatefulAggregateInstanceFactory aggregateRootInstanceFactory, Class<ID> aggregateIdType, Class<AGGREGATE_IMPL_TYPE> aggregateImplementationType, AggregateSnapshotRepository aggregateSnapshotRepository)
Create anStatefulAggregateRepositoryinstance that supports loading and persisting the given Aggregate type - if missing, theEventStorewill be configured with the defaultAggregateEventStreamConfigurationbased on theAggregateEventStreamConfigurationFactorythat theEventStore'sAggregateEventStreamPersistenceStrategyis configured with- Type Parameters:
CONFIG- the aggregate type configurationID- the aggregate ID typeEVENT_TYPE- the type of eventAGGREGATE_IMPL_TYPE- the concrete aggregate type (MUST be a subtype ofStatefulAggregate)- Parameters:
eventStore- theEventStoreinstance to useaggregateType- the aggregate type being handled by this repositoryaggregateRootInstanceFactory- the factory responsible for instantiating yourStatefulAggregate's when loading them from theEventStoreaggregateIdType- the concrete aggregate ID typeaggregateImplementationType- the concrete aggregate type (MUST be a subtype ofStatefulAggregate)aggregateSnapshotRepository- optional (may be null)AggregateSnapshotRepository- Returns:
- a repository instance that can be used load, add and query aggregates of type
aggregateType
-
tryLoad
default Optional<AGGREGATE_IMPL_TYPE> tryLoad(ID aggregateId, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder expectedLatestEventOrder)
Try to load anStatefulAggregateinstance with the specifiedaggregateIdfrom the underlyingEventStore
If the aggregate instance exists it will be associated with theUnitOfWorkFactory.getRequiredUnitOfWork()and any changes to will be tracked and will be persisted to the underlyingEventStorewhen theUnitOfWorkis committed.- Parameters:
aggregateId- the id of the aggregate we want to loadexpectedLatestEventOrder- the expectedEvent.eventOrder()of the last event stored in relation to the given aggregate instance- Returns:
- an
Optionalwith the matchingStatefulAggregateinstance if it exists, otherwise it will return anOptional.empty() - Throws:
OptimisticAggregateLoadException- in case theEvent.eventOrder()of the last event stored in relation to the given aggregate instance is different from theexpectedLatestEventOrder
-
tryLoad
Optional<AGGREGATE_IMPL_TYPE> tryLoad(ID aggregateId, Optional<dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder> expectedLatestEventOrder)
Try to load anStatefulAggregateinstance with the specifiedaggregateIdfrom the underlyingEventStore
If the aggregate instance exists it will be associated with theUnitOfWorkFactory.getRequiredUnitOfWork()and any changes to will be tracked and will be persisted to the underlyingEventStorewhen theUnitOfWorkis committed.- Parameters:
aggregateId- the id of the aggregate we want to loadexpectedLatestEventOrder- option with the expectedEvent.eventOrder()of the last event stored in relation to the given aggregate instance (if any)- Returns:
- an
Optionalwith the matchingStatefulAggregateinstance if it exists, otherwise it will return anOptional.empty() - Throws:
OptimisticAggregateLoadException- in case theEvent.eventOrder()of the last event stored in relation to the given aggregate instance is different from theexpectedLatestEventOrder
-
tryLoad
default Optional<AGGREGATE_IMPL_TYPE> tryLoad(ID aggregateId)
Try to load anStatefulAggregateinstance with the specifiedaggregateIdfrom the underlyingEventStore
If the aggregate instance exists it will be associated with theUnitOfWorkFactory.getRequiredUnitOfWork()and any changes to will be tracked and will be persisted to the underlyingEventStorewhen theUnitOfWorkis committed.- Parameters:
aggregateId- the id of the aggregate we want to load- Returns:
- an
Optionalwith the matchingStatefulAggregateinstance if it exists, otherwise it will return anOptional.empty() - Throws:
OptimisticAggregateLoadException- in case theEvent.eventOrder()of the last event stored in relation to the given aggregate instance is different from theexpectedLatestEventOrder
-
load
default AGGREGATE_IMPL_TYPE load(ID aggregateId)
Load anStatefulAggregateinstance with the specifiedaggregateIdfrom the underlyingEventStore
The loaded aggregate instance will be associated with theUnitOfWorkFactory.getRequiredUnitOfWork()and any changes to will be tracked and will be persisted to the underlyingEventStorewhen theUnitOfWorkis committed.- Parameters:
aggregateId- the id of the aggregate we want to load- Returns:
- an
Optionalwith the matchingStatefulAggregateinstance - Throws:
dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.AggregateNotFoundException- in case a matchingStatefulAggregatedoesn't exist in theEventStore
-
load
default AGGREGATE_IMPL_TYPE load(ID aggregateId, dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder expectedLatestEventOrder)
Load anStatefulAggregateinstance with the specifiedaggregateIdfrom the underlyingEventStore
The loaded aggregate instance will be associated with theUnitOfWorkFactory.getRequiredUnitOfWork()and any changes to will be tracked and will be persisted to the underlyingEventStorewhen theUnitOfWorkis committed.- Parameters:
aggregateId- the id of the aggregate we want to loadexpectedLatestEventOrder- the expectedEvent.eventOrder()of the last event stored in relation to the given aggregate instance- Returns:
- an
Optionalwith the matchingStatefulAggregateinstance - Throws:
dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.AggregateNotFoundException- in case a matchingStatefulAggregatedoesn't exist in theEventStore
-
save
AGGREGATE_IMPL_TYPE save(AGGREGATE_IMPL_TYPE aggregate)
Save/Associate a newly created and not yet persistedStatefulAggregateinstance with theUnitOfWorkFactory.getRequiredUnitOfWork()
Any changes to will be tracked and will be persisted to the underlyingEventStorewhen theUnitOfWorkis committed.- Parameters:
aggregate- the aggregate instance to persist to the underlyingEventStore- Returns:
- the persisted aggregate
-
persist
@Deprecated default void persist(AGGREGATE_IMPL_TYPE aggregate)
Deprecated.Usesave(StatefulAggregate)insteadSave/Associate a newly created and not yet persistedStatefulAggregateinstance with theUnitOfWorkFactory.getRequiredUnitOfWork()
Any changes to will be tracked and will be persisted to the underlyingEventStorewhen theUnitOfWorkis committed.- Parameters:
aggregate- the aggregate instance to persist to the underlyingEventStore
-
aggregateRootImplementationType
Class<AGGREGATE_IMPL_TYPE> aggregateRootImplementationType()
The type ofStatefulAggregateimplementation this repository handles
-
aggregateType
dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType()
The type ofAggregateTypethis repository is using to persist Events
-
-