void begin(final String phaseString) { try { if (!transaction.isActiveOrMarkedRollback()) { log.debug("beginning transaction " + phaseString); transaction.begin(); } } catch (Exception e) { throw new IllegalStateException("Could not start transaction", e); } }
void commitOrRollback(final String phaseString) { try { if (transaction.isActive()) { try { log.debug("committing transaction " + phaseString); transaction.commit(); } catch (IllegalStateException e) { log.warn( "TX commit failed with illegal state exception. This may be because the tx timed out and was rolled back in the background.", e); } } else if (transaction.isRolledBackOrMarkedRollback()) { log.debug("rolling back transaction " + phaseString); transaction.rollback(); } } catch (Exception e) { throw new IllegalStateException("Could not commit transaction", e); } }
public void enlist(EntityManager entityManager) throws SystemException { getSeamTransaction().enlist(entityManager); }
public final T workInTransaction(org.jboss.seam.transaction.SeamTransaction transaction) throws Exception { boolean transactionActive = transaction.isActiveOrMarkedRollback() || transaction.isRolledBack(); if (newTransactionRequired) { log.debug("beginning transaction"); transaction.begin(); if (transaction.isMarkedRollback()) { log.debug("rolling back transaction"); transaction.rollback(); } else { log.debug("committing transaction"); transaction.commit(); if (newTransactionRequired && transaction.getStatus() != Status.STATUS_NO_TRANSACTION) { if (ExceptionUtil.exceptionCausesRollback(e)) { log.debug("rolling back transaction"); transaction.rollback(); } else { log.debug("committing transaction after ApplicationException(rollback=false):" + e.getMessage()); transaction.commit(); } else if (transaction.getStatus() != Status.STATUS_NO_TRANSACTION && ExceptionUtil.exceptionCausesRollback(e)) { transaction.setRollbackOnly();
switch (this.tx.getStatus()) { case Status.STATUS_ACTIVE: this.log.debugf("Committing a transaction for request %s", sre.getServletRequest()); tx.commit(); break; case Status.STATUS_MARKED_ROLLBACK: case Status.STATUS_PREPARING: this.log.debugf("Rolling back a transaction for request %s", sre.getServletRequest()); tx.rollback(); break; case Status.STATUS_COMMITTED:
@Override public void requestInitialized(ServletRequestEvent sre) { final String listenerDisabledParam = sre.getServletContext().getInitParameter(DISABLE_LISTENER_PARAM); if (listenerDisabledParam != null && "true".equals(listenerDisabledParam.trim().toLowerCase())) { return; } try { if (this.tx.getStatus() == Status.STATUS_ACTIVE) { this.log.warn("Transaction was already started before the listener"); } else { this.log.debugf("Beginning transaction for request %s", sre.getServletRequest()); this.tx.begin(); } } catch (SystemException se) { this.log.warn("Error starting the transaction, or checking status", se); this.txException.fire(new ExceptionToCatch(se)); } catch (NotSupportedException e) { this.log.warn("Error starting the transaction", e); this.txException.fire(new ExceptionToCatch(e)); } } }
public boolean isActive() { lazyInitialization(); try { return userTransaction.isActive(); } catch (SystemException e) { throw new RuntimeException(e); } }
public boolean isActiveOrMarkedRollback() throws SystemException { return getSeamTransaction().isActiveOrMarkedRollback(); }
public void begin() throws NotSupportedException, SystemException { getSeamTransaction().begin(); }
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { getSeamTransaction().commit(); }
public boolean isRolledBackOrMarkedRollback() throws SystemException { return getSeamTransaction().isRolledBackOrMarkedRollback(); }
public void rollback() throws IllegalStateException, SecurityException, SystemException { getSeamTransaction().rollback(); }
public void markTransactionRollback(@Handles(precedence = Precedence.BUILT_IN, during = TraversalMode.BREADTH_FIRST) CaughtException<Throwable> t) { // Any exception that occurs is going to mark the transaction for rollback. try { switch (this.tx.getStatus()) { case Status.STATUS_ACTIVE: case Status.STATUS_COMMITTED: case Status.STATUS_COMMITTING: case Status.STATUS_MARKED_ROLLBACK: case Status.STATUS_PREPARED: case Status.STATUS_PREPARING: this.tx.setRollbackOnly(); break; case Status.STATUS_ROLLING_BACK: case Status.STATUS_UNKNOWN: case Status.STATUS_ROLLEDBACK: case Status.STATUS_NO_TRANSACTION: break; } } catch (SystemException e) { log.warn("Could not set transaction to rollback", e); } t.rethrow(); } }
public int getStatus() throws SystemException { return getSeamTransaction().getStatus(); }
public boolean isCommitted() throws SystemException { return getSeamTransaction().isCommitted(); }
public boolean isConversationContextRequired() { return getSeamTransaction().isConversationContextRequired(); }
public boolean isActive() throws SystemException { return getSeamTransaction().isActive(); }