Class StatefulAggregateRepository.DefaultStatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>
- java.lang.Object
-
- dk.cloudcreate.essentials.components.eventsourced.aggregates.stateful.StatefulAggregateRepository.DefaultStatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>
-
- Type Parameters:
ID- the aggregate ID typeAGGREGATE_IMPL_TYPE- the concrete aggregate type (MUST be a subtype ofStatefulAggregate)
- All Implemented Interfaces:
StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>
- Enclosing interface:
- StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>
public static class StatefulAggregateRepository.DefaultStatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>> extends Object implements StatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>
DefaultStatefulAggregateRepositoryimplementation. You can extend this class directly if you need to expand the supported method or useStatefulAggregateRepository.from(ConfigurableEventStore, AggregateEventStreamConfiguration, StatefulAggregateInstanceFactory, Class, Class)to create a default instance
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface dk.cloudcreate.essentials.components.eventsourced.aggregates.stateful.StatefulAggregateRepository
StatefulAggregateRepository.DefaultStatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>
-
-
Method Summary
All Methods Instance Methods Concrete 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 Eventsprotected dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.EventStoreeventStore()TheEventStorethat's being used for supportAGGREGATE_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.StringtoString()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
-
eventStore
protected dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.EventStore eventStore()
TheEventStorethat's being used for support
-
tryLoad
public Optional<AGGREGATE_IMPL_TYPE> tryLoad(ID aggregateId, Optional<dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder> expectedLatestEventOrder)
Description copied from interface:StatefulAggregateRepositoryTry 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.- Specified by:
tryLoadin interfaceStatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>- 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()
-
save
public AGGREGATE_IMPL_TYPE save(AGGREGATE_IMPL_TYPE aggregate)
Description copied from interface:StatefulAggregateRepositorySave/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.- Specified by:
savein interfaceStatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>- Parameters:
aggregate- the aggregate instance to persist to the underlyingEventStore- Returns:
- the persisted aggregate
-
aggregateIdType
public Class<ID> aggregateIdType()
Description copied from interface:StatefulAggregateRepositoryThe type of aggregate ID this repository uses- Specified by:
aggregateIdTypein interfaceStatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>
-
aggregateRootImplementationType
public Class<AGGREGATE_IMPL_TYPE> aggregateRootImplementationType()
Description copied from interface:StatefulAggregateRepositoryThe type ofStatefulAggregateimplementation this repository handles- Specified by:
aggregateRootImplementationTypein interfaceStatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>
-
aggregateType
public dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.eventstream.AggregateType aggregateType()
Description copied from interface:StatefulAggregateRepositoryThe type ofAggregateTypethis repository is using to persist Events- Specified by:
aggregateTypein interfaceStatefulAggregateRepository<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE extends StatefulAggregate<ID,EVENT_TYPE,AGGREGATE_IMPL_TYPE>>
-
-