Example usage for javax.transaction Status STATUS_COMMITTED

List of usage examples for javax.transaction Status STATUS_COMMITTED

Introduction

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

Prototype

int STATUS_COMMITTED

To view the source code for javax.transaction Status STATUS_COMMITTED.

Click Source Link

Document

A transaction is associated with the target object and it has been committed.

Usage

From source file:org.mule.util.xa.AbstractResourceManager.java

public void commitTransaction(AbstractTransactionContext context) throws ResourceManagerException {
    assureReady();//from   w  ww  . ja v  a 2  s  . c  o  m
    if (context.status == Status.STATUS_MARKED_ROLLBACK) {
        throw new ResourceManagerException(CoreMessages.transactionMarkedForRollback());
    }
    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);
        }
    }
}

From source file:org.nuxeo.ecm.core.event.impl.EventServiceImpl.java

@Override
public void afterCompletion(int status) {
    if (status == Status.STATUS_COMMITTED) {
        handleTxCommited();//  ww w . j  a  v a  2  s  .c om
    } else if (status == Status.STATUS_ROLLEDBACK) {
        handleTxRollbacked();
    } else {
        log.error("Unexpected afterCompletion status: " + status);
    }
}

From source file:org.nuxeo.ecm.core.management.jtajca.internal.DefaultTransactionMonitor.java

@Override
public void afterCompletion(int code) {
    DefaultTransactionStatistics stats = thisStatistics();
    if (stats == null) {
        return;/*ww w  . j  av  a  2 s  . c  o m*/
    }
    stats.endTimestamp = System.currentTimeMillis();
    stats.status = TransactionStatistics.Status.fromCode(code);
    switch (code) {
    case Status.STATUS_COMMITTED:
        lastCommittedStatistics = stats;
        break;
    case Status.STATUS_ROLLEDBACK:
        lastRollbackedStatistics = stats;
        stats.endCapturedContext = new Throwable("** rollback context **");
        break;
    }
}

From source file:org.nuxeo.elasticsearch.listener.ElasticSearchInlineListener.java

@Override
public void handleEvent(Event event) {
    String eventId = event.getName();
    if (!isEnlisted.get()) {
        if (event.isCommitEvent()) {
            // manual flush on save if TxManager is not hooked
            afterCompletion(Status.STATUS_COMMITTED);
            return;
        }/*www. j  av a2  s .  c om*/
        // try to enlist our listener
        isEnlisted.set(registerSynchronization(this));
    }
    if (!(event.getContext() instanceof DocumentEventContext)) {
        // don't process Events that are not tied to Documents
        return;
    }
    DocumentEventContext docCtx = (DocumentEventContext) event.getContext();
    stackCommand(docCtx, eventId);
}

From source file:org.springframework.transaction.jta.SpringJtaSynchronizationAdapter.java

/**
 * JTA {@code afterCompletion} callback: invoked after commit/rollback.
 * <p>Needs to invoke the Spring synchronization's {@code beforeCompletion}
 * at this late stage in case of a rollback, since there is no corresponding
 * callback with JTA./* ww  w . ja  va  2 s  .  c  o  m*/
 * @see org.springframework.transaction.support.TransactionSynchronization#beforeCompletion
 * @see org.springframework.transaction.support.TransactionSynchronization#afterCompletion
 */
@Override
public void afterCompletion(int status) {
    if (!this.beforeCompletionCalled) {
        // beforeCompletion not called before (probably because of JTA rollback).
        // Perform the cleanup here.
        this.springSynchronization.beforeCompletion();
    }
    // Call afterCompletion with the appropriate status indication.
    switch (status) {
    case Status.STATUS_COMMITTED:
        this.springSynchronization.afterCompletion(TransactionSynchronization.STATUS_COMMITTED);
        break;
    case Status.STATUS_ROLLEDBACK:
        this.springSynchronization.afterCompletion(TransactionSynchronization.STATUS_ROLLED_BACK);
        break;
    default:
        this.springSynchronization.afterCompletion(TransactionSynchronization.STATUS_UNKNOWN);
    }
}