当前位置: 首页>>代码示例>>Java>>正文


Java DefaultTransactionStatus类代码示例

本文整理汇总了Java中org.springframework.transaction.support.DefaultTransactionStatus的典型用法代码示例。如果您正苦于以下问题:Java DefaultTransactionStatus类的具体用法?Java DefaultTransactionStatus怎么用?Java DefaultTransactionStatus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DefaultTransactionStatus类属于org.springframework.transaction.support包,在下文中一共展示了DefaultTransactionStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: persistent

import org.springframework.transaction.support.DefaultTransactionStatus; //导入依赖的package包/类
public  Transaction persistent(Object status){
    TransactionId tID=TransactionId.get();
    String transactionKey=tID.getTransactionKey();
    //将事务状态放入集合
    List<Transaction> transactions=_TRANSACTION_HASH.containsKey(transactionKey)?_TRANSACTION_HASH.get(transactionKey):null;
    if(null==transactions) {
        STATUS_LOCK.writeLock().lock();
        transactions = null == transactions && _TRANSACTION_HASH.containsKey(transactionKey) ? _TRANSACTION_HASH.get(transactionKey) : transactions;
        if (null == transactions) {
            transactions = new CopyOnWriteArrayList<Transaction>();
            _TRANSACTION_HASH.put(transactionKey,transactions);
            _TRANSACTION_HOLD_TIMES.put(transactionKey,System.currentTimeMillis());
        }
        STATUS_LOCK.writeLock().unlock();
    }
    Transaction t=DBTransaction.createDbTransaction((DefaultTransactionStatus) status);
    transactions.add(t);
    return t;
}
 
开发者ID:zhangkewei,项目名称:dubbo-transaction,代码行数:20,代码来源:DBTransactionContext.java

示例2: doRollback

import org.springframework.transaction.support.DefaultTransactionStatus; //导入依赖的package包/类
@Override
protected void doRollback(DefaultTransactionStatus status) {
    TransactionContext transactionContext = getTransactionContext();
    long txId = getTransactionId();
    if (transactionContext == null) {
        logger.error(" [LITX] litx transaction has not been started. [TX ID: " + txId + "]");
        throw new RuntimeException("LITX: litx transaction has not been started. [TX ID: " + txId + "]");
    }
    if (transactionContext.isNeedRollback()) {
     logger.info(" [LITX]开始回滚事务 [TX ID: " + txId + "]");
     try {
     	transactionContext.doRollback();
     }catch(Exception e){
     	logger.error(" [LITX]回滚异常", e);
     }finally {
     	logger.info(" [LITX]回滚事务完成 [TX ID: " + txId + "]");
     }
    }
    super.doRollback(status);
}
 
开发者ID:thebeastshop,项目名称:litx,代码行数:21,代码来源:LitTransactionManager.java

示例3: doRollback

import org.springframework.transaction.support.DefaultTransactionStatus; //导入依赖的package包/类
@Override
protected void doRollback(DefaultTransactionStatus status) {
	JpaTransactionObject txObject = (JpaTransactionObject) status.getTransaction();
	if (status.isDebug()) {
		logger.debug("Rolling back JPA transaction on EntityManager [" +
				txObject.getEntityManagerHolder().getEntityManager() + "]");
	}
	try {
		EntityTransaction tx = txObject.getEntityManagerHolder().getEntityManager().getTransaction();
		if (tx.isActive()) {
			tx.rollback();
		}
	}
	catch (PersistenceException ex) {
		throw new TransactionSystemException("Could not roll back JPA transaction", ex);
	}
	finally {
		if (!txObject.isNewEntityManagerHolder()) {
			// Clear all pending inserts/updates/deletes in the EntityManager.
			// Necessary for pre-bound EntityManagers, to avoid inconsistent state.
			txObject.getEntityManagerHolder().getEntityManager().clear();
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:JpaTransactionManager.java

示例4: doCommit

import org.springframework.transaction.support.DefaultTransactionStatus; //导入依赖的package包/类
@Override
protected void doCommit(DefaultTransactionStatus status) {
	JdoTransactionObject txObject = (JdoTransactionObject) status.getTransaction();
	if (status.isDebug()) {
		logger.debug("Committing JDO transaction on PersistenceManager [" +
				txObject.getPersistenceManagerHolder().getPersistenceManager() + "]");
	}
	try {
		Transaction tx = txObject.getPersistenceManagerHolder().getPersistenceManager().currentTransaction();
		tx.commit();
	}
	catch (JDOException ex) {
		// Assumably failed to flush changes to database.
		throw convertJdoAccessException(ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:JdoTransactionManager.java

示例5: doRollback

import org.springframework.transaction.support.DefaultTransactionStatus; //导入依赖的package包/类
@Override
protected void doRollback(DefaultTransactionStatus status) {
	JdoTransactionObject txObject = (JdoTransactionObject) status.getTransaction();
	if (status.isDebug()) {
		logger.debug("Rolling back JDO transaction on PersistenceManager [" +
				txObject.getPersistenceManagerHolder().getPersistenceManager() + "]");
	}
	try {
		Transaction tx = txObject.getPersistenceManagerHolder().getPersistenceManager().currentTransaction();
		if (tx.isActive()) {
			tx.rollback();
		}
	}
	catch (JDOException ex) {
		throw new TransactionSystemException("Could not roll back JDO transaction", ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:JdoTransactionManager.java

示例6: prepareForCommit

import org.springframework.transaction.support.DefaultTransactionStatus; //导入依赖的package包/类
@Override
protected void prepareForCommit(DefaultTransactionStatus status) {
	if (this.earlyFlushBeforeCommit && status.isNewTransaction()) {
		HibernateTransactionObject txObject = (HibernateTransactionObject) status.getTransaction();
		Session session = txObject.getSessionHolder().getSession();
		if (!session.getFlushMode().lessThan(FlushMode.COMMIT)) {
			logger.debug("Performing an early flush for Hibernate transaction");
			try {
				session.flush();
			}
			catch (HibernateException ex) {
				throw convertHibernateAccessException(ex);
			}
			finally {
				session.setFlushMode(FlushMode.MANUAL);
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:HibernateTransactionManager.java

示例7: noExistingTransaction

import org.springframework.transaction.support.DefaultTransactionStatus; //导入依赖的package包/类
@Test
public void noExistingTransaction() {
	PlatformTransactionManager tm = new TestTransactionManager(false, true);
	DefaultTransactionStatus status1 = (DefaultTransactionStatus)
			tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_SUPPORTS));
	assertTrue("Must not have transaction", status1.getTransaction() == null);

	DefaultTransactionStatus status2 = (DefaultTransactionStatus)
			tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED));
	assertTrue("Must have transaction", status2.getTransaction() != null);
	assertTrue("Must be new transaction", status2.isNewTransaction());

	try {
		tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_MANDATORY));
		fail("Should not have thrown NoTransactionException");
	}
	catch (IllegalTransactionStateException ex) {
		// expected
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:TransactionSupportTests.java

示例8: existingTransaction

import org.springframework.transaction.support.DefaultTransactionStatus; //导入依赖的package包/类
@Test
public void existingTransaction() {
	PlatformTransactionManager tm = new TestTransactionManager(true, true);
	DefaultTransactionStatus status1 = (DefaultTransactionStatus)
			tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_SUPPORTS));
	assertTrue("Must have transaction", status1.getTransaction() != null);
	assertTrue("Must not be new transaction", !status1.isNewTransaction());

	DefaultTransactionStatus status2 = (DefaultTransactionStatus)
			tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED));
	assertTrue("Must have transaction", status2.getTransaction() != null);
	assertTrue("Must not be new transaction", !status2.isNewTransaction());

	try {
		DefaultTransactionStatus status3 = (DefaultTransactionStatus)
				tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_MANDATORY));
		assertTrue("Must have transaction", status3.getTransaction() != null);
		assertTrue("Must not be new transaction", !status3.isNewTransaction());
	}
	catch (NoTransactionException ex) {
		fail("Should not have thrown NoTransactionException");
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:TransactionSupportTests.java

示例9: wrapIfNeeded

import org.springframework.transaction.support.DefaultTransactionStatus; //导入依赖的package包/类
public static <T> AsyncFutureListener<T> wrapIfNeeded(AsyncFutureListener<T> listener, GigaSpace gigaSpace) {
    DefaultTransactionProvider txProvider = (DefaultTransactionProvider) gigaSpace.getTxProvider();
    JiniTransactionHolder holder = txProvider.getHolder();
    PlatformTransactionManager transactionManager = txProvider.getTransactionManager();
    if (holder == null || transactionManager == null) {
        // just wrap for exception translation
        return new InternalAsyncFutureListener<T>(gigaSpace, listener, null, transactionManager, holder);
    } 
    // here, we create a dummy transaction status (with its new transaction set to true, so the commit/roolback
    // process will be performed). We also increase the ref count of the transaction, so only the last one will
    // be performed
    AbstractJiniTransactionManager.JiniTransactionObject jiniTransactionObject = new AbstractJiniTransactionManager.JiniTransactionObject();
    jiniTransactionObject.setJiniHolder(holder, false);
    TransactionStatus txStatus = new DefaultTransactionStatus(jiniTransactionObject, true, false, false, false, null);
    holder.incRef();
    return new InternalAsyncFutureListener<T>(gigaSpace, listener, txStatus, transactionManager, holder);
}
 
开发者ID:Gigaspaces,项目名称:xap-openspaces,代码行数:18,代码来源:InternalAsyncFutureListener.java

示例10: commitTransactionAfterReturning

import org.springframework.transaction.support.DefaultTransactionStatus; //导入依赖的package包/类
/**
 * @see org.springframework.transaction.interceptor.TransactionAspectSupport#doCommitTransactionAfterReturning(org.springframework.transaction.interceptor.TransactionAspectSupport.TransactionInfo)
 */
@Override
protected void commitTransactionAfterReturning(TransactionInfo txInfo) {
    // using INFO level since DEBUG level turns on the (somewhat misleading) log statements of the superclass
    if (logger.isDebugEnabled()) {
        if (txInfo != null) {
            TransactionStatus txStatus = txInfo.getTransactionStatus();
            if (txStatus != null) {
                if (txStatus.isNewTransaction()) {
                    LOG.debug("committing explicit transaction for " + txInfo.getJoinpointIdentification());
                }
                else {
                    if (txStatus instanceof DefaultTransactionStatus) {
                        DefaultTransactionStatus dtxStatus = (DefaultTransactionStatus) txStatus;

                        if (dtxStatus.isNewSynchronization()) {
                            LOG.debug("committing implicit transaction for " + txInfo.getJoinpointIdentification());
                        }
                    }
                }
            }
        }
    }

    super.commitTransactionAfterReturning(txInfo);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:29,代码来源:KualiTransactionInterceptor.java

示例11: doCommit

import org.springframework.transaction.support.DefaultTransactionStatus; //导入依赖的package包/类
@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);
	}
	
	/**modify by guosg 这里提交ldtm事务*/
	SynchronizationManager.getCurrentUserTransation().commit();
}
 
开发者ID:gsgsdtc,项目名称:ldtm,代码行数:18,代码来源:LdtmDataSourceTransactionManager.java

示例12: doRollback

import org.springframework.transaction.support.DefaultTransactionStatus; //导入依赖的package包/类
@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);
	}
	
	/**modify by guosg 这里提交回滚事务*/
	SynchronizationManager.getCurrentUserTransation().rollback();
}
 
开发者ID:gsgsdtc,项目名称:ldtm,代码行数:18,代码来源:LdtmDataSourceTransactionManager.java

示例13: testNoExistingTransaction

import org.springframework.transaction.support.DefaultTransactionStatus; //导入依赖的package包/类
public void testNoExistingTransaction() {
	PlatformTransactionManager tm = new TestTransactionManager(false, true);
	DefaultTransactionStatus status1 = (DefaultTransactionStatus)
			tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_SUPPORTS));
	assertTrue("Must not have transaction", status1.getTransaction() == null);

	DefaultTransactionStatus status2 = (DefaultTransactionStatus)
			tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED));
	assertTrue("Must have transaction", status2.getTransaction() != null);
	assertTrue("Must be new transaction", status2.isNewTransaction());

	try {
		tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_MANDATORY));
		fail("Should not have thrown NoTransactionException");
	}
	catch (IllegalTransactionStateException ex) {
		// expected
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:20,代码来源:TransactionSupportTests.java

示例14: testExistingTransaction

import org.springframework.transaction.support.DefaultTransactionStatus; //导入依赖的package包/类
public void testExistingTransaction() {
	PlatformTransactionManager tm = new TestTransactionManager(true, true);
	DefaultTransactionStatus status1 = (DefaultTransactionStatus)
			tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_SUPPORTS));
	assertTrue("Must have transaction", status1.getTransaction() != null);
	assertTrue("Must not be new transaction", !status1.isNewTransaction());

	DefaultTransactionStatus status2 = (DefaultTransactionStatus)
			tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED));
	assertTrue("Must have transaction", status2.getTransaction() != null);
	assertTrue("Must not be new transaction", !status2.isNewTransaction());

	try {
		DefaultTransactionStatus status3 = (DefaultTransactionStatus)
				tm.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_MANDATORY));
		assertTrue("Must have transaction", status3.getTransaction() != null);
		assertTrue("Must not be new transaction", !status3.isNewTransaction());
	}
	catch (NoTransactionException ex) {
		fail("Should not have thrown NoTransactionException");
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:23,代码来源:TransactionSupportTests.java

示例15: process

import org.springframework.transaction.support.DefaultTransactionStatus; //导入依赖的package包/类
/**
 * Define how message exchanges are processed.
 *
 * @param exchange the InOut message exchange
 * @throws FcrepoOperationFailedException when the underlying HTTP request results in an error
 */
@Override
public void process(final Exchange exchange) throws FcrepoOperationFailedException {
    if (exchange.isTransacted()) {
        transactionTemplate.execute(new TransactionCallbackWithoutResult() {
            protected void doInTransactionWithoutResult(final TransactionStatus status) {
                final DefaultTransactionStatus st = (DefaultTransactionStatus)status;
                final FcrepoTransactionObject tx = (FcrepoTransactionObject)st.getTransaction();
                try {
                    doRequest(exchange, tx.getSessionId());
                } catch (FcrepoOperationFailedException ex) {
                    throw new TransactionSystemException(
                        "Error executing fcrepo request in transaction: ", ex);
                }
            }
        });
    } else {
        doRequest(exchange, null);
    }
}
 
开发者ID:fcrepo4-exts,项目名称:fcrepo-camel,代码行数:26,代码来源:FcrepoProducer.java


注:本文中的org.springframework.transaction.support.DefaultTransactionStatus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。