T
- The type that this aggregate storespublic abstract class LockingRepository<T,A extends Aggregate<T>> extends AbstractRepository<T,LockAwareAggregate<T,A>>
Modifier and Type | Class and Description |
---|---|
protected static class |
LockingRepository.Builder<T>
Abstract Builder class to instantiate
LockingRepository implementations. |
Modifier | Constructor and Description |
---|---|
protected |
LockingRepository(LockingRepository.Builder<T> builder)
Instantiate a
LockingRepository based on the fields contained in the LockingRepository.Builder . |
Modifier and Type | Method and Description |
---|---|
protected LockAwareAggregate<T,A> |
doCreateNew(Callable<T> factoryMethod)
Creates a new aggregate instance using the given
factoryMethod . |
protected abstract A |
doCreateNewForLock(Callable<T> factoryMethod)
Creates a new aggregate instance using the given
factoryMethod . |
protected void |
doDelete(LockAwareAggregate<T,A> aggregate)
Verifies whether all locks are valid and delegates to
doDeleteWithLock(Aggregate) to perform actual deleting. |
protected abstract void |
doDeleteWithLock(A aggregate)
Perform the actual deleting of the aggregate.
|
protected LockAwareAggregate<T,A> |
doLoad(String aggregateIdentifier,
Long expectedVersion)
Perform the actual loading of an aggregate.
|
protected abstract A |
doLoadWithLock(String aggregateIdentifier,
Long expectedVersion)
Loads the aggregate with the given aggregateIdentifier.
|
protected void |
doSave(LockAwareAggregate<T,A> aggregate)
Verifies whether all locks are valid and delegates to
doSaveWithLock(Aggregate) to perform actual storage. |
protected abstract void |
doSaveWithLock(A aggregate)
Perform the actual saving of the aggregate.
|
protected void |
prepareForCommit(LockAwareAggregate<T,A> aggregate)
Register handlers with the current Unit of Work that save or delete the given
aggregate when
the Unit of Work is committed. |
aggregateModel, canResolve, getAggregateType, load, load, managedAggregates, newInstance, postDelete, postSave, reportIllegalState, send, validateOnLoad
protected LockingRepository(LockingRepository.Builder<T> builder)
LockingRepository
based on the fields contained in the LockingRepository.Builder
.
A goal of the provided Builder is to create an AggregateModel
specifying generic T
as the
aggregate type to be stored. All aggregates in this repository must be instanceOf
this aggregate type.
To instantiate this AggregateModel, either an AggregateModel
can be provided directly or an
aggregateType
of type Class
can be used. The latter will internally resolve to an
AggregateModel. Thus, either the AggregateModel or the aggregateType
should be provided. An
AxonConfigurationException
is thrown if this criteria is not met.
Additionally will assert that the LockFactory
is not null
, resulting in an
AxonConfigurationException if this is the case.
builder
- the LockingRepository.Builder
used to instantiate a LockingRepository
instanceprotected LockAwareAggregate<T,A> doCreateNew(Callable<T> factoryMethod) throws Exception
AbstractRepository
factoryMethod
. Implementations should assume that this
method is only called if a UnitOfWork is currently active.doCreateNew
in class AbstractRepository<T,LockAwareAggregate<T,A extends Aggregate<T>>>
factoryMethod
- The method to create the aggregate's root instanceException
- when the factoryMethod throws an exceptionprotected abstract A doCreateNewForLock(Callable<T> factoryMethod) throws Exception
factoryMethod
. Implementations should assume that this
method is only called if a UnitOfWork is currently active.factoryMethod
- The method to create the aggregate's root instanceException
- when the factoryMethod throws an exceptionprotected LockAwareAggregate<T,A> doLoad(String aggregateIdentifier, Long expectedVersion)
doLoad
in class AbstractRepository<T,LockAwareAggregate<T,A extends Aggregate<T>>>
aggregateIdentifier
- the identifier of the aggregate to loadexpectedVersion
- The expected version of the aggregateAggregateNotFoundException
- if aggregate with given id cannot be foundprotected void prepareForCommit(LockAwareAggregate<T,A> aggregate)
AbstractRepository
aggregate
when
the Unit of Work is committed.prepareForCommit
in class AbstractRepository<T,LockAwareAggregate<T,A extends Aggregate<T>>>
aggregate
- The Aggregate to save or delete when the Unit of Work is committedprotected void doSave(LockAwareAggregate<T,A> aggregate)
doSaveWithLock(Aggregate)
to perform actual storage.doSave
in class AbstractRepository<T,LockAwareAggregate<T,A extends Aggregate<T>>>
aggregate
- the aggregate to storeprotected final void doDelete(LockAwareAggregate<T,A> aggregate)
doDeleteWithLock(Aggregate)
to perform actual deleting.doDelete
in class AbstractRepository<T,LockAwareAggregate<T,A extends Aggregate<T>>>
aggregate
- the aggregate to deleteprotected abstract void doSaveWithLock(A aggregate)
aggregate
- the aggregate to storeprotected abstract void doDeleteWithLock(A aggregate)
aggregate
- the aggregate to deleteprotected abstract A doLoadWithLock(String aggregateIdentifier, Long expectedVersion)
aggregateIdentifier
- the identifier of the aggregate to loadexpectedVersion
- The expected version of the aggregate to loadAggregateNotFoundException
- if the aggregate with given identifier does not existCopyright © 2010–2019. All rights reserved.