Пример #1
0
 @Override
 public void onPrepareCommit(
     UnitOfWork unitOfWork, Set<AggregateRoot> aggregateRoots, List<EventProxy> events) {
   if (hasPotentialConflicts()) {
     conflictResolver.resolveConflicts(asList(aggregate.getUncommittedEvents()), unseenEvents);
   }
 }
Пример #2
0
 /**
  * 执行真正的 保存 事件操作
  *
  * @param aggregate the aggregate to store
  */
 @Override
 protected void doSaveWithLock(T aggregate) {
   AggregateEventStream eventStream = aggregate.getUncommittedEvents();
   try {
     Iterator<EventStreamDecorator> iterator = eventStreamDecorators.descendingIterator();
     while (iterator.hasNext()) {
       eventStream =
           iterator.next().decorateForAppend(getTypeIdentifier(), aggregate, eventStream);
     }
     AggregateEventStore.appendEvents(getTypeIdentifier(), eventStream);
   } finally {
     IOUtils.closeQuietlyIfCloseable(eventStream);
   }
 }