Example usage for javax.transaction NotSupportedException getLocalizedMessage

List of usage examples for javax.transaction NotSupportedException getLocalizedMessage

Introduction

In this page you can find the example usage for javax.transaction NotSupportedException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.apache.openjpa.jdbc.kernel.TableJDBCSeq.java

/**
 * Updates the max available sequence value.
 *///from  ww  w .ja  va 2 s.c om
private void allocateSequence(JDBCStore store, ClassMapping mapping, Status stat, int alloc,
        boolean updateStatSeq) throws SQLException {
    Runnable runnable = new AllocateSequenceRunnable(store, mapping, stat, alloc, updateStatSeq);
    try {
        if (suspendInJTA()) {
            // NotSupportedException is wrapped in a StoreException by
            // the caller.
            try {
                _conf.getManagedRuntimeInstance().doNonTransactionalWork(runnable);
            } catch (NotSupportedException nse) {
                SQLException sqlEx = new SQLException(nse.getLocalizedMessage());
                sqlEx.initCause(nse);
                throw sqlEx;
            }
        } else {
            runnable.run();
        }
    } catch (RuntimeException re) {
        Throwable e = re.getCause();
        if (e instanceof SQLException)
            throw (SQLException) e;
        else
            throw re;
    }
}

From source file:org.wso2.carbon.attachment.mgt.core.dao.impl.TransactionManagerProvider.java

public void doNonTransactionalWork(java.lang.Runnable runnable) throws NotSupportedException {
    TransactionManager transactionManager = null;
    Transaction transaction = null;//from   www  . j  av a2 s .  c  o m

    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;
    }
}