@Override protected void prepareForCommit(LockAwareAggregate<T, A> aggregate) { Assert.state(aggregate.isLockHeld(), () -> "An aggregate is being used for which a lock is no longer held"); super.prepareForCommit(aggregate); }
/** * Verifies whether all locks are valid and delegates to * {@link #doDeleteWithLock(Aggregate)} to perform actual deleting. * * @param aggregate the aggregate to delete */ @Override protected final void doDelete(LockAwareAggregate<T, A> aggregate) { if (aggregate.version() != null && !aggregate.isLockHeld()) { throw new ConcurrencyException(String.format( "The aggregate of type [%s] with identifier [%s] could not be " + "saved, as a valid lock is not held. Either another thread has saved an aggregate, or " + "the current thread had released its lock earlier on.", aggregate.getClass().getSimpleName(), aggregate.identifierAsString())); } doDeleteWithLock(aggregate.getWrappedAggregate()); }
/** * Verifies whether all locks are valid and delegates to * {@link #doSaveWithLock(Aggregate)} to perform actual storage. * * @param aggregate the aggregate to store */ @Override protected void doSave(LockAwareAggregate<T, A> aggregate) { if (aggregate.version() != null && !aggregate.isLockHeld()) { throw new ConcurrencyException(String.format( "The aggregate of type [%s] with identifier [%s] could not be " + "saved, as a valid lock is not held. Either another thread has saved an aggregate, or " + "the current thread had released its lock earlier on.", aggregate.getClass().getSimpleName(), aggregate.identifierAsString())); } doSaveWithLock(aggregate.getWrappedAggregate()); }