本文整理汇总了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);
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}