Example usage for javax.transaction SystemException getMessage

List of usage examples for javax.transaction SystemException getMessage

Introduction

In this page you can find the example usage for javax.transaction SystemException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java

public synchronized void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
        SecurityException, IllegalStateException, SystemException {

    CompensableLogger compensableLogger = this.beanFactory.getCompensableLogger();

    this.transactionContext.setCompensating(true);
    this.transactionStatus = Status.STATUS_COMMITTING;
    compensableLogger.updateTransaction(this.getTransactionArchive());

    SystemException systemEx = null;
    try {// www .j  ava2s .c o  m
        this.fireNativeParticipantConfirm();
    } catch (SystemException ex) {
        systemEx = ex;

        logger.info("{}| confirm native branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
    } catch (RuntimeException ex) {
        systemEx = new SystemException(ex.getMessage());

        logger.info("{}| confirm native branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
    }

    try {
        this.fireRemoteParticipantConfirm();
    } catch (HeuristicMixedException ex) {
        logger.info("{}| confirm remote branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
        throw ex;
    } catch (HeuristicRollbackException ex) {
        logger.info("{}| confirm remote branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
        throw ex;
    } catch (SystemException ex) {
        logger.info("{}| confirm remote branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
        throw ex;
    } catch (RuntimeException ex) {
        logger.info("{}| confirm remote branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
        throw ex;
    }

    if (systemEx != null) {
        throw systemEx;
    } else {
        this.transactionStatus = Status.STATUS_COMMITTED;
        compensableLogger.updateTransaction(this.getTransactionArchive());
        logger.info("{}| compensable transaction committed!",
                ByteUtils.byteArrayToString(transactionContext.getXid().getGlobalTransactionId()));
    }

}

From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java

public synchronized void rollback() throws IllegalStateException, SystemException {
    CompensableLogger compensableLogger = this.beanFactory.getCompensableLogger();

    this.transactionStatus = Status.STATUS_ROLLING_BACK;
    this.transactionContext.setCompensating(true);

    compensableLogger.updateTransaction(this.getTransactionArchive());

    boolean coordinator = this.transactionContext.isCoordinator();
    boolean coordinatorTried = false;
    for (int i = 0; coordinator && i < this.archiveList.size(); i++) {
        CompensableArchive compensableArchive = this.archiveList.get(i);
        coordinatorTried = compensableArchive.isTried() ? true : coordinatorTried;
    }//from ww  w  .  j  a v  a  2  s.  co m

    SystemException systemEx = null;
    if (coordinator == false || coordinatorTried) {
        try {
            this.fireNativeParticipantCancel();
        } catch (SystemException ex) {
            systemEx = ex;

            logger.info("{}| cancel native branchs failed!",
                    ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
        } catch (RuntimeException ex) {
            systemEx = new SystemException(ex.getMessage());

            logger.info("{}| cancel native branchs failed!",
                    ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
        }
    }

    try {
        this.fireRemoteParticipantCancel();
    } catch (SystemException ex) {
        logger.info("{}| cancel remote branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
        throw ex;
    } catch (RuntimeException ex) {
        logger.info("{}| cancel remote branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
        throw new SystemException(ex.getMessage());
    }

    if (systemEx != null) {
        throw systemEx;
    } else {
        this.transactionStatus = Status.STATUS_ROLLEDBACK;
        compensableLogger.updateTransaction(this.getTransactionArchive());
        logger.info("{}| compensable transaction rolled back!",
                ByteUtils.byteArrayToString(transactionContext.getXid().getGlobalTransactionId()));
    }

}

From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java

public synchronized void recoveryCommit() throws CommitRequiredException, SystemException {
    CompensableLogger compensableLogger = this.beanFactory.getCompensableLogger();

    this.transactionContext.setCompensating(true);
    this.transactionStatus = Status.STATUS_COMMITTING;
    compensableLogger.updateTransaction(this.getTransactionArchive());

    SystemException systemEx = null;
    try {/*  w  ww  . j  a  va 2 s.c  o  m*/
        this.fireNativeParticipantRecoveryConfirm();
    } catch (SystemException ex) {
        systemEx = ex;

        logger.info("{}| recovery-confirm native branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
    } catch (RuntimeException ex) {
        systemEx = new SystemException(ex.getMessage());

        logger.info("{}| recovery-confirm native branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
    }

    try {
        this.fireRemoteParticipantRecoveryConfirm();
    } catch (HeuristicMixedException ex) {
        logger.info("{}| recovery-confirm remote branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
        throw new SystemException(ex.getMessage());
    } catch (HeuristicRollbackException ex) {
        logger.info("{}| recovery-confirm remote branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
        throw new SystemException(ex.getMessage());
    } catch (SystemException ex) {
        logger.info("{}| recovery-confirm remote branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
        throw ex;
    } catch (RuntimeException ex) {
        logger.info("{}| recovery-confirm remote branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
        throw new SystemException(ex.getMessage());
    }

    if (systemEx != null) {
        throw systemEx;
    } else {
        this.transactionStatus = Status.STATUS_COMMITTED;
        compensableLogger.updateTransaction(this.getTransactionArchive());
        logger.info("{}| compensable transaction recovery committed!",
                ByteUtils.byteArrayToString(transactionContext.getXid().getGlobalTransactionId()));
    }

}

From source file:org.bytesoft.bytetcc.CompensableTransactionImpl.java

public synchronized void recoveryRollback() throws RollbackRequiredException, SystemException {
    CompensableLogger compensableLogger = this.beanFactory.getCompensableLogger();

    this.transactionStatus = Status.STATUS_ROLLING_BACK;
    this.transactionContext.setCompensating(true);
    compensableLogger.updateTransaction(this.getTransactionArchive());

    SystemException systemEx = null;
    try {//  w  ww.  ja v  a2  s  .  c  o m
        this.fireNativeParticipantRecoveryCancel();
    } catch (SystemException ex) {
        systemEx = ex;

        logger.info("{}| recovery-cancel native branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
    } catch (RuntimeException ex) {
        systemEx = new SystemException(ex.getMessage());

        logger.info("{}| recovery-cancel native branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
    }

    try {
        this.fireRemoteParticipantRecoveryCancel();
    } catch (SystemException ex) {
        logger.info("{}| recovery-cancel remote branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
        throw ex;
    } catch (RuntimeException ex) {
        logger.info("{}| recovery-cancel remote branchs failed!",
                ByteUtils.byteArrayToString(this.transactionContext.getXid().getGlobalTransactionId()), ex);
        throw new SystemException(ex.getMessage());
    }

    if (systemEx != null) {
        throw systemEx;
    } else {
        this.transactionStatus = Status.STATUS_ROLLEDBACK;
        compensableLogger.updateTransaction(this.getTransactionArchive());
        logger.info("{}| compensable transaction recovery rolled back!",
                ByteUtils.byteArrayToString(transactionContext.getXid().getGlobalTransactionId()));
    }

}

From source file:org.exolab.castor.jdo.engine.GlobalDatabaseImpl.java

/**
 * @inheritDoc// w  ww . j  a  v  a 2  s  .c  om
 */
public void beforeCompletion() {
    // XXX [SMH]: Find another test for txNotInProgress
    if (_transaction == null || _ctx == null || !_ctx.isOpen()) {
        throw new IllegalStateException(Messages.message("jdo.txNotInProgress"));
    }

    registerSynchronizables();

    if (_ctx.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
        try {
            _transaction.setRollbackOnly();
        } catch (SystemException except) {
            _log.warn(Messages.format("jdo.warnException", except));
        }
        return;
    }
    try {
        _ctx.prepare();
    } catch (TransactionAbortedException tae) {
        _log.error(Messages.format("jdo.txAbortedMarkRollback", tae.getMessage()), tae);
        try {
            _transaction.setRollbackOnly();
        } catch (SystemException se) {
            _log.fatal(Messages.format("jdo.txMarkRollbackFailure", se.getMessage()), se);
        }
        _ctx.rollback();
    }
}