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


Java JtaTransactionManager.setUserTransaction方法代码示例

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


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

示例1: testSetJtaTransactionManager

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
@Test
public void testSetJtaTransactionManager() throws Exception {
	DataSource ds = mock(DataSource.class);
	TransactionManager tm = mock(TransactionManager.class);
	UserTransaction ut = mock(UserTransaction.class);
	TransactionSynchronizationRegistry tsr = mock(TransactionSynchronizationRegistry.class);
	JtaTransactionManager jtm = new JtaTransactionManager();
	jtm.setTransactionManager(tm);
	jtm.setUserTransaction(ut);
	jtm.setTransactionSynchronizationRegistry(tsr);
	LocalSessionFactoryBuilder lsfb = new LocalSessionFactoryBuilder(ds);
	lsfb.setJtaTransactionManager(jtm);
	Object jtaPlatform = lsfb.getProperties().get(AvailableSettings.JTA_PLATFORM);
	assertNotNull(jtaPlatform);
	assertSame(tm, jtaPlatform.getClass().getMethod("retrieveTransactionManager").invoke(jtaPlatform));
	assertSame(ut, jtaPlatform.getClass().getMethod("retrieveUserTransaction").invoke(jtaPlatform));
	assertTrue(lsfb.getProperties().get(AvailableSettings.TRANSACTION_STRATEGY) instanceof CMTTransactionFactory);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:HibernateTransactionManagerTests.java

示例2: testSerializable

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
public void testSerializable() throws Exception {
	UserTransaction ut1 = mock(UserTransaction.class);
	UserTransaction ut2 = mock(UserTransaction.class);
	TransactionManager tm = mock(TransactionManager.class);

	JtaTransactionManager jtam = new JtaTransactionManager();
	jtam.setUserTransaction(ut1);
	jtam.setTransactionManager(tm);
	jtam.setRollbackOnCommitFailure(true);
	jtam.afterPropertiesSet();

	SimpleNamingContextBuilder jndiEnv = SimpleNamingContextBuilder
			.emptyActivatedContextBuilder();
	jndiEnv.bind(JtaTransactionManager.DEFAULT_USER_TRANSACTION_NAME, ut2);
	JtaTransactionManager serializedJtatm = (JtaTransactionManager) SerializationTestUtils
			.serializeAndDeserialize(jtam);

	// should do client-side lookup
	assertNotNull("Logger must survive serialization",
			serializedJtatm.logger);
	assertTrue("UserTransaction looked up on client", serializedJtatm
			.getUserTransaction() == ut2);
	assertNull("TransactionManager didn't survive", serializedJtatm
			.getTransactionManager());
	assertEquals(true, serializedJtatm.isRollbackOnCommitFailure());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:27,代码来源:JtaTransactionManagerSerializationTests.java

示例3: serializable

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
@Test
public void serializable() throws Exception {
	UserTransaction ut1 = mock(UserTransaction.class);
	UserTransaction ut2 = mock(UserTransaction.class);
	TransactionManager tm = mock(TransactionManager.class);

	JtaTransactionManager jtam = new JtaTransactionManager();
	jtam.setUserTransaction(ut1);
	jtam.setTransactionManager(tm);
	jtam.setRollbackOnCommitFailure(true);
	jtam.afterPropertiesSet();

	SimpleNamingContextBuilder jndiEnv = SimpleNamingContextBuilder
			.emptyActivatedContextBuilder();
	jndiEnv.bind(JtaTransactionManager.DEFAULT_USER_TRANSACTION_NAME, ut2);
	JtaTransactionManager serializedJtatm = (JtaTransactionManager) SerializationTestUtils
			.serializeAndDeserialize(jtam);

	// should do client-side lookup
	assertNotNull("Logger must survive serialization",
			serializedJtatm.logger);
	assertTrue("UserTransaction looked up on client", serializedJtatm
			.getUserTransaction() == ut2);
	assertNull("TransactionManager didn't survive", serializedJtatm
			.getTransactionManager());
	assertEquals(true, serializedJtatm.isRollbackOnCommitFailure());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:28,代码来源:JtaTransactionManagerSerializationTests.java

示例4: createTransactionManager

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
@Produces
@Named("jtaTransactionManager")
public PlatformTransactionManager createTransactionManager() {
    JtaTransactionManager jtaTransactionManager = new JtaTransactionManager();
    jtaTransactionManager.setUserTransaction(userTransaction);
    jtaTransactionManager.afterPropertiesSet();
    return jtaTransactionManager;
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel-examples,代码行数:9,代码来源:TransactionManagerProducer.java

示例5: createTransactionManager

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
@Produces
@Named("transactionManager")
public PlatformTransactionManager createTransactionManager() {
    JtaTransactionManager jtaTransactionManager = new JtaTransactionManager();
    jtaTransactionManager.setUserTransaction(userTransaction);
    jtaTransactionManager.setTransactionManager(transactionManager);
    jtaTransactionManager.afterPropertiesSet();
    return jtaTransactionManager;
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel-examples,代码行数:10,代码来源:TransactionManagerProducer.java

示例6: transactionManager

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
@Bean
public PlatformTransactionManager transactionManager() {
    JtaTransactionManager jtaTransactionManager = new JtaTransactionManager();
    jtaTransactionManager.setTransactionManager(atomikosTransactionManager());
    jtaTransactionManager.setUserTransaction(userTransaction());
    return jtaTransactionManager;
}
 
开发者ID:flowable,项目名称:flowable-examples,代码行数:8,代码来源:Configuration.java

示例7: transactionManager

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
@Bean
public JtaTransactionManager transactionManager() {
	JtaTransactionManager tm = new JtaTransactionManager();
	tm.setTransactionManager(bitronixTransactionManager());
	tm.setUserTransaction(bitronixTransactionManager());
	tm.setAllowCustomIsolationLevels(true);

	return tm;
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:10,代码来源:JtaConfiguration.java


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