Example #1
0
 private void doReleaseLock(final String sagaId, final Saga sagaInstance) {
   if (sagaInstance == null || !CurrentUnitOfWork.isStarted()) {
     lock.releaseLock(sagaId);
   } else if (CurrentUnitOfWork.isStarted()) {
     CurrentUnitOfWork.get()
         .registerListener(
             new UnitOfWorkListenerAdapter() {
               @Override
               public void onCleanup(UnitOfWork unitOfWork) {
                 // a reference to the saga is maintained to prevent it from GC until after the UoW
                 // commit
                 lock.releaseLock(sagaInstance.getSagaIdentifier());
               }
             });
   }
 }
Example #2
0
 private void removeEntry(final String sagaIdentifier, final Map<String, ?> sagaMap) {
   if (!CurrentUnitOfWork.isStarted()) {
     sagaMap.remove(sagaIdentifier);
   } else {
     CurrentUnitOfWork.get()
         .registerListener(
             new UnitOfWorkListenerAdapter() {
               @Override
               public void afterCommit(UnitOfWork unitOfWork) {
                 sagaMap.remove(sagaIdentifier);
               }
             });
   }
 }