Example usage for javax.transaction NotSupportedException NotSupportedException

List of usage examples for javax.transaction NotSupportedException NotSupportedException

Introduction

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

Prototype

public NotSupportedException(String msg) 

Source Link

Usage

From source file:com.impetus.kundera.persistence.jta.KunderaJTAUserTransaction.java

@Override
public void begin() throws NotSupportedException, SystemException {
    log.info("beginning JTA transaction");

    isTransactionInProgress = true;/* w  w  w  . j a va2 s .c  om*/
    Transaction tx = threadLocal.get();
    if (tx != null) {
        if ((tx.getStatus() == Status.STATUS_MARKED_ROLLBACK)) {
            throw new NotSupportedException("Nested Transaction not supported!");
        }
    }

    Integer timer = timerThead.get();
    threadLocal.set(new KunderaTransaction(timer != null ? timer : DEFAULT_TIME_OUT));
}

From source file:org.alfresco.util.transaction.SpringAwareUserTransaction.java

/**
 * @throws NotSupportedException if an attempt is made to reuse this instance
 *//*from  w  w  w. j  ava 2  s .  c  om*/
public synchronized void begin() throws NotSupportedException, SystemException {
    // make sure that the status and info align - the result may or may not be null
    @SuppressWarnings("unused")
    TransactionInfo txnInfo = getTransactionInfo();
    if (internalStatus != Status.STATUS_NO_TRANSACTION) {
        throw new NotSupportedException("The UserTransaction may not be reused");
    }

    // check 

    if ((propagationBehaviour != TransactionDefinition.PROPAGATION_REQUIRES_NEW)) {
        if (!readOnly && TransactionSynchronizationManager.isSynchronizationActive()
                && TransactionSynchronizationManager.isCurrentTransactionReadOnly()) {
            throw new IllegalStateException("Nested writable transaction in a read only transaction");
        }
    }

    // begin a transaction
    try {
        internalTxnInfo = createTransactionIfNecessary((Method) null, (Class<?>) null); // super class will just pass nulls back to us
    } catch (CannotCreateTransactionException e) {
        throw new ConnectionPoolException("The DB connection pool is depleted.", e);
    }

    internalStatus = Status.STATUS_ACTIVE;
    threadId = Thread.currentThread().getId();

    // Record that transaction details now that begin was successful
    isBeginMatched = false;
    if (isCallStackTraced) {
        // get the stack trace
        Exception e = new Exception();
        e.fillInStackTrace();
        beginCallStack = e.getStackTrace();
    }

    // done
    if (logger.isDebugEnabled()) {
        logger.debug("Began user transaction: " + this);
    }
}

From source file:org.exoplatform.forum.service.impl.JCRDataStorage.java

/**
 * @deprecated use {@link #getPosts(PostFilter, int, int)}
 *///from  w w  w  .  j a v a2 s  .co m
public JCRPageList getPosts(String categoryId, String forumId, String topicId, String isApproved,
        String isHidden, String strQuery, String userLogin) throws Exception {
    try {
        String isWaiting = strQuery.equals("true") || strQuery.equals("false") ? strQuery : "";
        PostFilter filter = new PostFilter(categoryId, forumId, topicId, isApproved, isHidden, isWaiting,
                userLogin);

        if (!Utils.isEmpty(strQuery)) {
            throw new NotSupportedException("The method not support add more query.");
        }

        return new ForumPageList(null, 10, makePostsSQLQuery(filter, true), true);
    } catch (PathNotFoundException e) {
        return null;
    }
}

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;/*  w w  w .  j a va2  s  . c  om*/

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