@Override public void afterDelivery() throws ResourceException { final TransactionManager tm = getTransactionManager(); try { if (currentTx != null) { if (currentTx.getStatus() == Status.STATUS_MARKED_ROLLBACK) tm.rollback(); else tm.commit(); currentTx = null; } if (previousTx != null) { tm.resume(previousTx); previousTx = null; } } catch (InvalidTransactionException e) { throw new LocalTransactionException(e); } catch (HeuristicMixedException e) { throw new LocalTransactionException(e); } catch (SystemException e) { throw new LocalTransactionException(e); } catch (HeuristicRollbackException e) { throw new LocalTransactionException(e); } catch (RollbackException e) { throw new LocalTransactionException(e); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(previousClassLoader); previousClassLoader = null; } }
protected void localTransactionStart(boolean isSPI) throws ResourceException { Connection c = physicalConnection; try { c.setAutoCommit(false); } catch (SQLException e) { throw new LocalTransactionException("Unable to disable autoCommit", e); } super.localTransactionStart(isSPI); }
@Override public void commit() throws ResourceException { try { final Transactions.Transaction transaction = transactions.currentTransaction(); if (transaction == null) { throw new LocalTransactionException("A local transaction does not exist"); } transaction.commit(); } catch (RollbackException | HeuristicMixedException | HeuristicRollbackException | SystemException e) { throw new LocalTransactionException(e); } }
protected void localTransactionStart(boolean isSPI) throws ResourceException { Connection c = physicalConnection; try { c.setAutoCommit(false); } catch (SQLException e) { throw new LocalTransactionException("Unable to disable autoCommit", e); } super.localTransactionStart(isSPI); }
protected void localTransactionStart(boolean isSPI) throws ResourceException { Connection c = physicalConnection; try { c.setAutoCommit(false); } catch (SQLException e) { throw new LocalTransactionException("Unable to disable autoCommit", e); } super.localTransactionStart(isSPI); }
@Override public void begin() throws ResourceException { try { transactions.begin(); } catch (NotSupportedException | SystemException | RollbackException e) { throw new LocalTransactionException(e); } }
@Override public void rollback() throws ResourceException { final Transactions.Transaction transaction = transactions.currentTransaction(); if (transaction == null) { throw new LocalTransactionException("A local transaction does not exist"); } try { transaction.rollback(); } catch (SystemException e) { throw new LocalTransactionException(e); } } }
protected void localTransactionCommit(boolean isSPI) throws ResourceException { Connection c = physicalConnection; try { if (commitBeforeAutoCommit) { c.commit(); } c.setAutoCommit(true); } catch (SQLException e) { try { c.rollback(); } catch (SQLException e1) { if (log != null) { e.printStackTrace(log); } } throw new LocalTransactionException("Unable to commit", e); } super.localTransactionCommit(isSPI); }
protected void localTransactionRollback(boolean isSPI) throws ResourceException { Connection c = physicalConnection; try { c.rollback(); } catch (SQLException e) { throw new LocalTransactionException("Unable to rollback", e); } super.localTransactionRollback(isSPI); try { c.setAutoCommit(true); } catch (SQLException e) { throw new ResourceAdapterInternalException("Unable to enable autoCommit after rollback", e); } }
@Override public void afterDelivery() throws ResourceException { final TransactionManager tm = getTransactionManager(); try { if (currentTx != null) { if (currentTx.getStatus() == Status.STATUS_MARKED_ROLLBACK) tm.rollback(); else tm.commit(); currentTx = null; } if (previousTx != null) { tm.resume(previousTx); previousTx = null; } } catch (InvalidTransactionException e) { throw new LocalTransactionException(e); } catch (HeuristicMixedException e) { throw new LocalTransactionException(e); } catch (SystemException e) { throw new LocalTransactionException(e); } catch (HeuristicRollbackException e) { throw new LocalTransactionException(e); } catch (RollbackException e) { throw new LocalTransactionException(e); } finally { doPrivileged(contextClassLoader(previousClassLoader)); previousClassLoader = null; } }
protected void localTransactionRollback(boolean isSPI) throws ResourceException { Connection c = physicalConnection; try { c.rollback(); } catch (SQLException e) { throw new LocalTransactionException("Unable to rollback", e); } super.localTransactionRollback(isSPI); try { c.setAutoCommit(true); } catch (SQLException e) { throw new ResourceAdapterInternalException("Unable to enable autoCommit after rollback", e); } }
protected void localTransactionRollback(boolean isSPI) throws ResourceException { Connection c = physicalConnection; try { c.rollback(); } catch (SQLException e) { throw new LocalTransactionException("Unable to rollback", e); } super.localTransactionRollback(isSPI); try { c.setAutoCommit(true); } catch (SQLException e) { throw new ResourceAdapterInternalException("Unable to enable autoCommit after rollback", e); } }
protected void localTransactionCommit(boolean isSPI) throws ResourceException { Connection c = physicalConnection; try { // according to the JDBC spec, reenabling autoCommit commits any current transaction // we need to do both here, so we rely on this behaviour in the driver as otherwise // commit followed by setAutoCommit(true) may result in 2 commits in the database if (mcf instanceof AutocommitSpecCompliant && (((AutocommitSpecCompliant) mcf).isCommitBeforeAutocommit() != null) && ((AutocommitSpecCompliant) mcf).isCommitBeforeAutocommit().booleanValue()) { c.commit(); } c.setAutoCommit(true); } catch (SQLException e) { try { c.rollback(); } catch (SQLException e1) { if (log != null) { e.printStackTrace(log); } } throw new LocalTransactionException("Unable to commit", e); } super.localTransactionCommit(isSPI); }
protected void localTransactionCommit(boolean isSPI) throws ResourceException { Connection c = physicalConnection; try { // according to the JDBC spec, reenabling autoCommit commits any current transaction // we need to do both here, so we rely on this behaviour in the driver as otherwise // commit followed by setAutoCommit(true) may result in 2 commits in the database if (mcf instanceof AutocommitSpecCompliant && (((AutocommitSpecCompliant) mcf).isCommitBeforeAutocommit() != null) && ((AutocommitSpecCompliant) mcf).isCommitBeforeAutocommit().booleanValue()) { c.commit(); } c.setAutoCommit(true); } catch (SQLException e) { try { c.rollback(); } catch (SQLException e1) { if (log != null) { e.printStackTrace(log); } } throw new LocalTransactionException("Unable to commit", e); } super.localTransactionCommit(isSPI); }
throw new LocalTransactionException("Local transaction has not begun."); throw new LocalTransactionException("Rollback of the transacted JMS " + "session failed: " + exc);
/** * Rollsback the local transaction. * * @exception CommException If the wrapped physical connection * is lost. * @exception LocalTransactionException If the local transaction has not * begun, or if the rollback fails. */ public synchronized void rollback() throws ResourceException { if (logger.isLoggable(BasicLevel.DEBUG)) logger.log(BasicLevel.DEBUG, this + " rollback()"); if (! isValid()) throw new CommException("Physical connection to the underlying JORAM server has been lost."); if (! startedLocalTx) throw new LocalTransactionException("Local transaction has not begun."); try { session.rollback(); } catch (JMSException exc) { throw new LocalTransactionException("Rollback of the transacted JMS session failed: " + exc); } ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK); ConnectionEventListener listener; for (int i = 0; i < listeners.size(); i++) { listener = (ConnectionEventListener) listeners.get(i); listener.localTransactionRolledback(event); } startedLocalTx = false; }
throw new LocalTransactionException("Local transaction has not begun."); throw new LocalTransactionException("Commit of the transacted JMS " + "session failed: " + exc);
throw new LocalTransactionException("Local transaction has not begun."); throw new LocalTransactionException("Commit of the transacted JMS " + "session failed: " + exc);
/** * Notifies that the local transaction is beginning. * * @exception CommException If the wrapped physical connection * is lost. * @exception LocalTransactionException If a local transaction has already * begun. */ public synchronized void begin() throws ResourceException { if (logger.isLoggable(BasicLevel.DEBUG)) logger.log(BasicLevel.DEBUG, this + " begin()"); if (! isValid()) throw new CommException("Physical connection to the underlying " + "JORAM server has been lost."); if (startedLocalTx) throw new LocalTransactionException("Local transaction has " + "already begun."); ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.LOCAL_TRANSACTION_STARTED); ConnectionEventListener listener; for (int i = 0; i < listeners.size(); i++) { listener = (ConnectionEventListener) listeners.get(i); listener.localTransactionStarted(event); } startedLocalTx = true; }
/** * Notifies that the local transaction is beginning. * * @exception CommException If the wrapped physical connection * is lost. * @exception LocalTransactionException If a local transaction has already * begun. */ public synchronized void begin() throws ResourceException { if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG)) AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG, this + " begin()"); if (! isValid()) throw new CommException("Physical connection to the underlying " + "JORAM server has been lost."); if (startedLocalTx) throw new LocalTransactionException("Local transaction has " + "already begun."); ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.LOCAL_TRANSACTION_STARTED); ConnectionEventListener listener; for (int i = 0; i < listeners.size(); i++) { listener = (ConnectionEventListener) listeners.get(i); listener.localTransactionStarted(event); } startedLocalTx = true; }