List of usage examples for javax.transaction TransactionManager rollback
public void rollback() throws IllegalStateException, SecurityException, SystemException;
From source file:org.wso2.carbon.dataservices.core.description.xa.DSSXATransactionManager.java
public void rollback() { TransactionManager txManager = getTransactionManager(); if (txManager == null) { return;/*from www . ja va2s . c om*/ } try { txManager.rollback(); } catch (Exception e) { log.warn("Error from transaction manager when " + "rollbacking: " + e.getMessage(), e); } finally { this.beginTx.set(false); } }
From source file:org.wso2.carbon.humantask.core.scheduler.SimpleScheduler.java
public <T> T execTransaction(Callable<T> transaction, int timeout) throws Exception { TransactionManager txm = transactionManager; if (txm == null) { throw new HumanTaskException( "Cannot locate the transaction manager; " + "the server might be shutting down."); }//w w w . j a v a 2 s.c o m // The value of the timeout is in seconds. If the value is zero, // the transaction service restores the default value. if (timeout < 0) { throw new IllegalArgumentException("Timeout must be positive, received: " + timeout); } boolean existingTransaction; try { existingTransaction = txm.getTransaction() != null; } catch (Exception ex) { String errMsg = "Internal Error, could not get current transaction."; throw new HumanTaskException(errMsg, ex); } // already in transaction, execute and return directly if (existingTransaction) { return transaction.call(); } // run in new transaction Exception ex = null; // int immediateRetryCount = _immediateTransactionRetryLimit; transactionManager.setTransactionTimeout(timeout); if (log.isDebugEnabled() && timeout != 0) { log.debug("Custom transaction timeout: " + timeout); } try { try { if (log.isDebugEnabled()) { log.debug("Beginning a new transaction"); } txm.begin(); } catch (Exception e) { String errMsg = "Internal Error, could not begin transaction."; throw new HumanTaskException(errMsg, e); } try { ex = null; return transaction.call(); } catch (Exception e) { ex = e; } finally { if (ex == null) { if (log.isDebugEnabled()) { log.debug("Committing on " + txm + "..."); } try { txm.commit(); } catch (Exception e2) { ex = e2; } } else { if (log.isDebugEnabled()) { log.debug("Rollbacking on " + txm + "..."); } txm.rollback(); } // if (ex != null && immediateRetryCount > 0) { // if (log.isDebugEnabled()) { // log.debug("Will retry the transaction in " + // _immediateTransactionRetryInterval + " msecs on " + // transactionManager + " for error: ", ex); // } // Thread.sleep(_immediateTransactionRetryInterval); // } } } finally { // 0 restores the default value transactionManager.setTransactionTimeout(0); } throw ex; }
From source file:org.wso2.carbon.rssmanager.core.RSSTransactionManager.java
public void rollback() throws RSSManagerException { TransactionManager txManager = getTransactionManager(); try {/*from w ww . j av a2 s . c om*/ if (!this.hasNoActiveTransaction()) { if (log.isDebugEnabled()) { log.debug("transactionManager.rollback()"); } txManager.rollback(); } } catch (Exception e) { throw new RSSManagerException("Error from transaction manager when rollbacking", e); } finally { this.beginTx.set(false); } }
From source file:org.wso2.carbon.rssmanager.data.mgt.retriever.util.StorageUsageTransactionManager.java
public void rollback() throws UsageManagerException { TransactionManager txManager = getTransactionManager(); try {//from w w w . j a v a 2s. c o m if (!this.hasNoActiveTransaction()) { if (log.isDebugEnabled()) { log.debug("transactionManager.rollback()"); } txManager.rollback(); } } catch (Exception e) { throw new UsageManagerException("Error from transaction manager when rollbacking", e); } finally { this.beginTx.set(false); } }