@Override protected Object doSuspend(Object transaction) { JtaTransactionObject txObject = (JtaTransactionObject) transaction; try { return doJtaSuspend(txObject); } catch (SystemException ex) { throw new TransactionSystemException("JTA failure on suspend", ex); } }
/** * This implementation checks the UserTransaction's rollback-only flag. */ @Override public boolean isRollbackOnly() { try { int jtaStatus = this.userTransaction.getStatus(); return (jtaStatus == Status.STATUS_MARKED_ROLLBACK || jtaStatus == Status.STATUS_ROLLEDBACK); } catch (SystemException ex) { throw new TransactionSystemException("JTA failure on getStatus", ex); } }
private Object loadWebLogicTransactionHelper() throws TransactionSystemException { Object helper = this.transactionHelper; if (helper == null) { try { Class<?> transactionHelperClass = getClass().getClassLoader().loadClass(TRANSACTION_HELPER_CLASS_NAME); Method getTransactionHelperMethod = transactionHelperClass.getMethod("getTransactionHelper"); helper = getTransactionHelperMethod.invoke(null); this.transactionHelper = helper; logger.trace("WebLogic TransactionHelper found"); } catch (InvocationTargetException ex) { throw new TransactionSystemException( "WebLogic's TransactionHelper.getTransactionHelper() method failed", ex.getTargetException()); } catch (Exception ex) { throw new TransactionSystemException( "Could not initialize WebLogicJtaTransactionManager because WebLogic API classes are not available", ex); } } return helper; }
@Override @Nullable protected TransactionManager retrieveTransactionManager() throws TransactionSystemException { Object helper = loadWebLogicTransactionHelper(); try { logger.trace("Retrieving JTA TransactionManager from WebLogic TransactionHelper"); Method getTransactionManagerMethod = helper.getClass().getMethod("getTransactionManager"); return (TransactionManager) getTransactionManagerMethod.invoke(this.transactionHelper); } catch (InvocationTargetException ex) { throw new TransactionSystemException( "WebLogic's TransactionHelper.getTransactionManager() method failed", ex.getTargetException()); } catch (Exception ex) { throw new TransactionSystemException( "Could not invoke WebLogic's TransactionHelper.getTransactionManager() method", ex); } }
@Override @Nullable protected UserTransaction retrieveUserTransaction() throws TransactionSystemException { Object helper = loadWebLogicTransactionHelper(); try { logger.trace("Retrieving JTA UserTransaction from WebLogic TransactionHelper"); Method getUserTransactionMethod = helper.getClass().getMethod("getUserTransaction"); return (UserTransaction) getUserTransactionMethod.invoke(this.transactionHelper); } catch (InvocationTargetException ex) { throw new TransactionSystemException( "WebLogic's TransactionHelper.getUserTransaction() method failed", ex.getTargetException()); } catch (Exception ex) { throw new TransactionSystemException( "Could not invoke WebLogic's TransactionHelper.getUserTransaction() method", ex); } }
@Override protected void doResume(@Nullable Object transaction, Object suspendedResources) { JtaTransactionObject txObject = (JtaTransactionObject) transaction; try { doJtaResume(txObject, suspendedResources); } catch (InvalidTransactionException ex) { throw new IllegalTransactionStateException("Tried to resume invalid JTA transaction", ex); } catch (IllegalStateException ex) { throw new TransactionSystemException("Unexpected internal transaction state", ex); } catch (SystemException ex) { throw new TransactionSystemException("JTA failure on resume", ex); } }
@Override protected boolean isExistingTransaction(Object transaction) { JtaTransactionObject txObject = (JtaTransactionObject) transaction; try { return (txObject.getUserTransaction().getStatus() != Status.STATUS_NO_TRANSACTION); } catch (SystemException ex) { throw new TransactionSystemException("JTA failure on getStatus", ex); } }
/** * Look up the WebSphere UOWManager in JNDI via the configured name. * @param uowManagerName the JNDI name of the UOWManager * @return the UOWManager object * @throws TransactionSystemException if the JNDI lookup failed * @see #setJndiTemplate * @see #setUowManagerName */ protected UOWManager lookupUowManager(String uowManagerName) throws TransactionSystemException { try { if (logger.isDebugEnabled()) { logger.debug("Retrieving WebSphere UOWManager from JNDI location [" + uowManagerName + "]"); } return getJndiTemplate().lookup(uowManagerName, UOWManager.class); } catch (NamingException ex) { throw new TransactionSystemException( "WebSphere UOWManager is not available at JNDI location [" + uowManagerName + "]", ex); } }
/** * Look up the JTA 1.1 TransactionSynchronizationRegistry in JNDI via the configured name. * <p>Can be overridden in subclasses to provide a different TransactionManager object. * @param registryName the JNDI name of the * TransactionSynchronizationRegistry * @return the TransactionSynchronizationRegistry object * @throws TransactionSystemException if the JNDI lookup failed * @see #setJndiTemplate * @see #setTransactionSynchronizationRegistryName */ protected TransactionSynchronizationRegistry lookupTransactionSynchronizationRegistry(String registryName) throws TransactionSystemException { try { if (logger.isDebugEnabled()) { logger.debug("Retrieving JTA TransactionSynchronizationRegistry from JNDI location [" + registryName + "]"); } return getJndiTemplate().lookup(registryName, TransactionSynchronizationRegistry.class); } catch (NamingException ex) { throw new TransactionSystemException( "JTA TransactionSynchronizationRegistry is not available at JNDI location [" + registryName + "]", ex); } }
/** * This implementation rolls back to the given JDBC 3.0 Savepoint. * @see java.sql.Connection#rollback(java.sql.Savepoint) */ @Override public void rollbackToSavepoint(Object savepoint) throws TransactionException { ConnectionHolder conHolder = getConnectionHolderForSavepoint(); try { conHolder.getConnection().rollback((Savepoint) savepoint); conHolder.resetRollbackOnly(); } catch (Throwable ex) { throw new TransactionSystemException("Could not roll back to JDBC savepoint", ex); } }
@Override protected void doCommit(DefaultTransactionStatus status) { DataSourceTransactionObject txObject = (DataSourceTransactionObject) status.getTransaction(); Connection con = txObject.getConnectionHolder().getConnection(); if (status.isDebug()) { logger.debug("Committing JDBC transaction on Connection [" + con + "]"); } try { con.commit(); } catch (SQLException ex) { throw new TransactionSystemException("Could not commit JDBC transaction", ex); } }
@Override protected void doRollback(DefaultTransactionStatus status) { DataSourceTransactionObject txObject = (DataSourceTransactionObject) status.getTransaction(); Connection con = txObject.getConnectionHolder().getConnection(); if (status.isDebug()) { logger.debug("Rolling back JDBC transaction on Connection [" + con + "]"); } try { con.rollback(); } catch (SQLException ex) { throw new TransactionSystemException("Could not roll back JDBC transaction", ex); } }
@Override protected void doRollback(DefaultTransactionStatus status) { CciLocalTransactionObject txObject = (CciLocalTransactionObject) status.getTransaction(); Connection con = txObject.getConnectionHolder().getConnection(); if (status.isDebug()) { logger.debug("Rolling back CCI local transaction on Connection [" + con + "]"); } try { con.getLocalTransaction().rollback(); } catch (LocalTransactionException ex) { throw new TransactionSystemException("Could not roll back CCI local transaction", ex); } catch (ResourceException ex) { throw new TransactionSystemException("Unexpected failure on rollback of CCI local transaction", ex); } }
@Override protected void doCommit(DefaultTransactionStatus status) { CciLocalTransactionObject txObject = (CciLocalTransactionObject) status.getTransaction(); Connection con = txObject.getConnectionHolder().getConnection(); if (status.isDebug()) { logger.debug("Committing CCI local transaction on Connection [" + con + "]"); } try { con.getLocalTransaction().commit(); } catch (LocalTransactionException ex) { throw new TransactionSystemException("Could not commit CCI local transaction", ex); } catch (ResourceException ex) { throw new TransactionSystemException("Unexpected failure on commit of CCI local transaction", ex); } }
@Override protected void doSetRollbackOnly(DefaultTransactionStatus status) { JtaTransactionObject txObject = (JtaTransactionObject) status.getTransaction(); if (status.isDebug()) { logger.debug("Setting JTA transaction rollback-only"); } try { int jtaStatus = txObject.getUserTransaction().getStatus(); if (jtaStatus != Status.STATUS_NO_TRANSACTION && jtaStatus != Status.STATUS_ROLLEDBACK) { txObject.getUserTransaction().setRollbackOnly(); } } catch (IllegalStateException ex) { throw new TransactionSystemException("Unexpected internal transaction state", ex); } catch (SystemException ex) { throw new TransactionSystemException("JTA failure on setRollbackOnly", ex); } }
@Override protected void doRollback(DefaultTransactionStatus status) { JmsTransactionObject txObject = (JmsTransactionObject) status.getTransaction(); Session session = txObject.getResourceHolder().getSession(); if (session != null) { try { if (status.isDebug()) { logger.debug("Rolling back JMS transaction on Session [" + session + "]"); } session.rollback(); } catch (JMSException ex) { throw new TransactionSystemException("Could not roll back JMS transaction", ex); } } }
@Override protected void doCommit(DefaultTransactionStatus status) throws TransactionException { RedissonTransactionObject to = (RedissonTransactionObject) status.getTransaction(); try { to.getTransactionHolder().getTransaction().commit(); } catch (TransactionException e) { throw new TransactionSystemException("Unable to commit transaction", e); } }
@Override protected void doRollback(DefaultTransactionStatus status) throws TransactionException { RedissonTransactionObject to = (RedissonTransactionObject) status.getTransaction(); try { to.getTransactionHolder().getTransaction().rollback(); } catch (TransactionException e) { throw new TransactionSystemException("Unable to commit transaction", e); } }
@Override protected void doRollback(DefaultTransactionStatus status) throws TransactionException { RedissonTransactionObject to = (RedissonTransactionObject) status.getTransaction(); try { to.getTransactionHolder().getTransaction().rollback(); } catch (TransactionException e) { throw new TransactionSystemException("Unable to commit transaction", e); } }
@Override protected void doCommit(DefaultTransactionStatus status) { JmsTransactionObject txObject = (JmsTransactionObject) status.getTransaction(); Session session = txObject.getResourceHolder().getSession(); if (session != null) { try { if (status.isDebug()) { logger.debug("Committing JMS transaction on Session [" + session + "]"); } session.commit(); } catch (TransactionRolledBackException ex) { throw new UnexpectedRollbackException("JMS transaction rolled back", ex); } catch (JMSException ex) { throw new TransactionSystemException("Could not commit JMS transaction", ex); } } }