List of usage examples for javax.transaction Status STATUS_NO_TRANSACTION
int STATUS_NO_TRANSACTION
To view the source code for javax.transaction Status STATUS_NO_TRANSACTION.
Click Source Link
From source file:org.milyn.db.JndiDataSourceTest.java
public void test_jta_new_transaction() throws Exception { when(connection.getAutoCommit()).thenReturn(true); when(transaction.getStatus()).thenReturn(Status.STATUS_NO_TRANSACTION); executeSmooks("jta", "test_jta_new_transaction", REPORT); verify(dataSource, atLeastOnce()).getConnection(); verify(transaction).begin();/* w w w . j a va 2s . c om*/ verify(connection).setAutoCommit(false); verify(transaction).commit(); verify(connection).close(); verify(transaction, never()).rollback(); verify(connection, never()).commit(); verify(connection, never()).rollback(); }
From source file:org.milyn.db.JndiDataSourceTest.java
public void test_jta_exception() throws Exception { when(connection.getAutoCommit()).thenReturn(false); when(transaction.getStatus()).thenReturn(Status.STATUS_NO_TRANSACTION); executeSmooksWithException("jta_exception", "test_jta_exception", REPORT); verify(dataSource, atLeastOnce()).getConnection(); verify(transaction).begin();// ww w.j a v a 2 s . c o m verify(transaction).rollback(); verify(connection).close(); verify(transaction, never()).commit(); verify(transaction, never()).setRollbackOnly(); verify(connection, never()).setAutoCommit(false); verify(connection, never()).commit(); verify(connection, never()).rollback(); }
From source file:org.nuxeo.runtime.transaction.TransactionHelper.java
/** * Checks if there is no transaction/*w w w .j av a 2 s. c om*/ * * @6.0 */ public static boolean isNoTransaction() { int status = getTransactionStatus(); return status == Status.STATUS_NO_TRANSACTION || status == -1; }
From source file:org.sakaiproject.kernel.webapp.filter.SakaiRequestFilter.java
/** * @throws SystemException//from w w w . j a va 2s . c om * @throws SecurityException * */ protected void commit() throws SecurityException, SystemException { try { if (Status.STATUS_NO_TRANSACTION != transactionManager.getStatus()) { transactionManager.commit(); } } catch (RollbackException e) { if (debug) LOG.debug(e); } catch (IllegalStateException e) { if (debug) LOG.debug(e); } catch (HeuristicMixedException e) { LOG.warn(e); } catch (HeuristicRollbackException e) { LOG.warn(e); } }
From source file:org.springframework.data.neo4j.support.DelegatingGraphDatabase.java
@Override public boolean transactionIsRunning() { if (!(delegate instanceof AbstractGraphDatabase)) { return true; // assume always running tx (e.g. for REST or other remotes) }//from www.j a va2 s . c om try { final TransactionManager txManager = ((AbstractGraphDatabase) delegate).getConfig().getTxModule() .getTxManager(); return txManager.getStatus() != Status.STATUS_NO_TRANSACTION; } catch (SystemException e) { log.error("Error accessing TransactionManager", e); return false; } }
From source file:org.springframework.data.neo4j.support.GraphDatabaseContext.java
/** * @return true if a transaction manager is available and a transaction is currently running *///from w ww. j a v a 2 s .c o m public boolean transactionIsRunning() { if (!(graphDatabaseService instanceof AbstractGraphDatabase)) { return true; // assume always running tx (e.g. for REST or other remotes) } try { final TransactionManager txManager = ((AbstractGraphDatabase) graphDatabaseService).getConfig() .getTxModule().getTxManager(); return txManager.getStatus() != Status.STATUS_NO_TRANSACTION; } catch (SystemException e) { log.error("Error accessing TransactionManager", e); return false; } }
From source file:org.wso2.carbon.dataservices.core.description.xa.DSSXATransactionManager.java
public boolean isInDTX() { TransactionManager txManager = getTransactionManager(); if (txManager == null) { return false; }/*from www.ja v a2 s . c o m*/ try { return txManager.getStatus() != Status.STATUS_NO_TRANSACTION; } catch (Exception e) { log.error("Error at 'hasNoActiveTransaction'", e); return false; } }
From source file:org.wso2.carbon.rssmanager.core.RSSTransactionManager.java
public boolean hasNoActiveTransaction() { try {/*from w ww .j ava2 s . c o m*/ return this.getTransactionManager().getStatus() == Status.STATUS_NO_TRANSACTION; } catch (Exception e) { log.error("Error at 'hasNoActiveTransaction'", e); return false; } }
From source file:org.xchain.namespaces.jta.TransactionCommand.java
public boolean execute(JXPathContext context) throws Exception { boolean managingTransaction = false; boolean result = false; UserTransaction transaction = ContainerContext.getJtaLookupStrategy().getUserTransaction(); if (transaction != null) { try {/*from www . j a v a 2 s . c om*/ // if there is not a transaction running, then start one. if (Status.STATUS_ACTIVE != transaction.getStatus()) { managingTransaction = true; transaction.setTransactionTimeout(this.getTimeout(context)); transaction.begin(); } // put the transaction into the context. ((ScopedQNameVariables) context.getVariables()).declareVariable(getResult(context), transaction, Scope.execution); // execute the chain result = super.execute(context); // roll back the transaction. if (managingTransaction) { transaction.commit(); } } catch (Exception e) { if (managingTransaction) { if (transaction.getStatus() != Status.STATUS_NO_TRANSACTION) { transaction.rollback(); } } throw e; } finally { // TODO: If we defined the transaction variable, then we should remove it. } } else { // TODO: Should this throw an IllegalStateException? Returning true seems like the wrong behavior. result = true; } return result; }