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


Java UserTransactionManager.getTransaction方法代码示例

本文整理汇总了Java中com.atomikos.icatch.jta.UserTransactionManager.getTransaction方法的典型用法代码示例。如果您正苦于以下问题:Java UserTransactionManager.getTransaction方法的具体用法?Java UserTransactionManager.getTransaction怎么用?Java UserTransactionManager.getTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.atomikos.icatch.jta.UserTransactionManager的用法示例。


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

示例1: getTransactionAssistant

import com.atomikos.icatch.jta.UserTransactionManager; //导入方法依赖的package包/类
/** before calling this method, please ensure you have called {@link TransactionConfigurator#setup(String, CommitRollbackCallback)} */
@Override
public TransactionAssistant getTransactionAssistant() throws ResourceException {
	//enlist a new resource into the transaction. it will be delisted, when its closed.
	final CommitRollbackCallback commitRollbackCallback = TransactionConfigurator.getCommitRollbackCallback(jndiName);
	MicroserviceXAResource ms = new MicroserviceXAResource(jndiName, commitRollbackCallback);
	UserTransactionManager utm = getTM();
	try {
		if(utm.getStatus() == Status.STATUS_NO_TRANSACTION){
			throw new ResourceException("no transaction found. please start one before getting the transaction assistant. status was: " + utm.getStatus());
		}
		Transaction tx = utm.getTransaction();
		tx.enlistResource(ms);
		return new AtomikosTransactionAssistantImpl(ms);
	} catch (Exception e) {
		throw new ResourceException("Unable to get transaction status", e);
	}
}
 
开发者ID:maxant,项目名称:genericconnector,代码行数:19,代码来源:BasicTransactionAssistanceFactoryImpl.java

示例2: close

import com.atomikos.icatch.jta.UserTransactionManager; //导入方法依赖的package包/类
@Override
public void close() {
	UserTransactionManager utm = getTransactionManager();
	try {
		if(utm.getStatus() == Status.STATUS_NO_TRANSACTION){
			throw new RuntimeException("no transaction found. please start one before getting the transaction assistant. status was: " + utm.getStatus());
		}
		Transaction tx = utm.getTransaction();
		tx.delistResource(ms, ms.getUnderlyingConnection().wasExecuteSuccessful() ? XAResource.TMSUCCESS : XAResource.TMFAIL);
	} catch (Exception e) {
		throw new RuntimeException("Unable to delist resource from transaction", e);
	}
}
 
开发者ID:maxant,项目名称:genericconnector,代码行数:14,代码来源:AtomikosTransactionAssistantImpl.java


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