示例#1
0
 public void rollbackTransaction(AbstractTransactionContext context)
     throws ResourceManagerException {
   assureReady();
   synchronized (context) {
     if (logger.isDebugEnabled()) {
       logger.debug("Rolling back transaction " + context);
     }
     try {
       context.status = Status.STATUS_ROLLING_BACK;
       doRollback(context);
       context.status = Status.STATUS_ROLLEDBACK;
     } catch (Error e) {
       setDirty(context, e);
       throw e;
     } catch (RuntimeException e) {
       setDirty(context, e);
       throw e;
     } catch (ResourceManagerSystemException e) {
       setDirty(context, e);
       throw e;
     } finally {
       globalTransactions.remove(context);
       context.finalCleanUp();
       // tell shutdown thread this tx is finished
       context.notifyFinish();
     }
     if (logger.isDebugEnabled()) {
       logger.debug("Rolled back transaction " + context);
     }
   }
 }
示例#2
0
 public void commitTransaction(AbstractTransactionContext context)
     throws ResourceManagerException {
   assureReady();
   if (context.status == Status.STATUS_MARKED_ROLLBACK) {
     throw new ResourceManagerException(new Message(Messages.TX_MARKED_FOR_ROLLBACK));
   }
   synchronized (context) {
     if (logger.isDebugEnabled()) {
       logger.debug("Committing transaction " + context);
     }
     try {
       context.status = Status.STATUS_COMMITTING;
       doCommit(context);
       context.status = Status.STATUS_COMMITTED;
     } catch (Error e) {
       setDirty(context, e);
       throw e;
     } catch (RuntimeException e) {
       setDirty(context, e);
       throw e;
     } catch (ResourceManagerSystemException e) {
       setDirty(context, e);
       throw e;
     } catch (ResourceManagerException e) {
       logger.warn("Could not commit tx " + context + ", rolling back instead", e);
       doRollback(context);
     } finally {
       globalTransactions.remove(context);
       context.finalCleanUp();
       // tell shutdown thread this tx is finished
       context.notifyFinish();
     }
     if (logger.isDebugEnabled()) {
       logger.debug("Committed transaction " + context);
     }
   }
 }