Search in sources :

Example 1 with GeneralException

use of org.apache.openjpa.util.GeneralException in project carbon-business-process by wso2.

the class TransactionManagerProvider method doNonTransactionalWork.

public void doNonTransactionalWork(Runnable runnable) throws NotSupportedException {
    TransactionManager tm;
    Transaction transaction;
    try {
        tm = getTransactionManager();
        transaction = tm.suspend();
    } catch (Exception e) {
        NotSupportedException nse = new NotSupportedException(e.getMessage());
        nse.initCause(e);
        throw nse;
    }
    runnable.run();
    try {
        tm.resume(transaction);
    } catch (Exception e) {
        try {
            transaction.setRollbackOnly();
        } catch (SystemException se2) {
            throw new GeneralException(se2);
        }
        NotSupportedException nse = new NotSupportedException(e.getMessage());
        nse.initCause(e);
        throw nse;
    }
}
Also used : GeneralException(org.apache.openjpa.util.GeneralException) Transaction(javax.transaction.Transaction) SystemException(javax.transaction.SystemException) TransactionManager(javax.transaction.TransactionManager) NotSupportedException(javax.transaction.NotSupportedException) GeneralException(org.apache.openjpa.util.GeneralException) NotSupportedException(javax.transaction.NotSupportedException) SystemException(javax.transaction.SystemException)

Example 2 with GeneralException

use of org.apache.openjpa.util.GeneralException in project carbon-business-process by wso2.

the class TransactionManagerProvider method doNonTransactionalWork.

public void doNonTransactionalWork(java.lang.Runnable runnable) throws NotSupportedException {
    TransactionManager transactionManager = null;
    Transaction transaction = null;
    try {
        transactionManager = getTransactionManager();
        transaction = transactionManager.suspend();
    } catch (Exception e) {
        NotSupportedException nse = new NotSupportedException(e.getMessage());
        nse.initCause(e);
        log.error(nse.getLocalizedMessage(), nse);
        throw nse;
    }
    runnable.run();
    try {
        transactionManager.resume(transaction);
    } catch (Exception e) {
        log.error(e.getLocalizedMessage(), e);
        try {
            transaction.setRollbackOnly();
        } catch (SystemException se2) {
            throw new GeneralException(se2);
        }
        NotSupportedException nse = new NotSupportedException(e.getMessage());
        nse.initCause(e);
        throw nse;
    }
}
Also used : GeneralException(org.apache.openjpa.util.GeneralException) Transaction(javax.transaction.Transaction) SystemException(javax.transaction.SystemException) TransactionManager(javax.transaction.TransactionManager) NotSupportedException(javax.transaction.NotSupportedException) GeneralException(org.apache.openjpa.util.GeneralException) NotSupportedException(javax.transaction.NotSupportedException) SystemException(javax.transaction.SystemException)

Example 3 with GeneralException

use of org.apache.openjpa.util.GeneralException in project carbon-business-process by wso2.

the class TransactionManagerProvider method doNonTransactionalWork.

public void doNonTransactionalWork(Runnable runnable) throws NotSupportedException {
    TransactionManager tm;
    Transaction transaction;
    try {
        tm = getTransactionManager();
        transaction = tm.suspend();
    } catch (Exception e) {
        NotSupportedException nse = new NotSupportedException(e.getMessage());
        nse.initCause(e);
        throw nse;
    }
    runnable.run();
    try {
        tm.resume(transaction);
    } catch (Exception e) {
        try {
            transaction.setRollbackOnly();
        } catch (SystemException se2) {
            throw new GeneralException(se2);
        }
        NotSupportedException nse = new NotSupportedException(e.getMessage());
        nse.initCause(e);
        throw nse;
    }
}
Also used : GeneralException(org.apache.openjpa.util.GeneralException) Transaction(javax.transaction.Transaction) SystemException(javax.transaction.SystemException) TransactionManager(javax.transaction.TransactionManager) NotSupportedException(javax.transaction.NotSupportedException) GeneralException(org.apache.openjpa.util.GeneralException) NotSupportedException(javax.transaction.NotSupportedException) SystemException(javax.transaction.SystemException)

Example 4 with GeneralException

use of org.apache.openjpa.util.GeneralException in project carbon-business-process by wso2.

the class TransactionManagerProvider method doNonTransactionalWork.

public void doNonTransactionalWork(java.lang.Runnable runnable) throws NotSupportedException {
    TransactionManager tm;
    Transaction transaction;
    try {
        tm = getTransactionManager();
        transaction = tm.suspend();
    } catch (Exception e) {
        NotSupportedException nse = new NotSupportedException(e.getMessage());
        nse.initCause(e);
        throw nse;
    }
    runnable.run();
    try {
        tm.resume(transaction);
    } catch (Exception e) {
        try {
            transaction.setRollbackOnly();
        } catch (SystemException se2) {
            throw new GeneralException(se2);
        }
        NotSupportedException nse = new NotSupportedException(e.getMessage());
        nse.initCause(e);
        throw nse;
    }
}
Also used : GeneralException(org.apache.openjpa.util.GeneralException) Transaction(javax.transaction.Transaction) SystemException(javax.transaction.SystemException) TransactionManager(javax.transaction.TransactionManager) NotSupportedException(javax.transaction.NotSupportedException) GeneralException(org.apache.openjpa.util.GeneralException) NotSupportedException(javax.transaction.NotSupportedException) SystemException(javax.transaction.SystemException)

Aggregations

NotSupportedException (javax.transaction.NotSupportedException)4 SystemException (javax.transaction.SystemException)4 Transaction (javax.transaction.Transaction)4 TransactionManager (javax.transaction.TransactionManager)4 GeneralException (org.apache.openjpa.util.GeneralException)4