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


Java JtaTransactionManager.afterPropertiesSet方法代码示例

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


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

示例1: jtaTransactionManagerWithCommitAndSynchronizationNever

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
@Test
public void jtaTransactionManagerWithCommitAndSynchronizationNever() throws Exception {
	UserTransaction ut = mock(UserTransaction.class);
	given(ut.getStatus()).willReturn(
	Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE);

	JtaTransactionManager ptm = newJtaTransactionManager(ut);
	TransactionTemplate tt = new TransactionTemplate(ptm);
	ptm.setTransactionSynchronization(JtaTransactionManager.SYNCHRONIZATION_NEVER);
	ptm.afterPropertiesSet();

	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
	tt.execute(new TransactionCallbackWithoutResult() {
		@Override
		protected void doInTransactionWithoutResult(TransactionStatus status) {
			assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
		}
	});
	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());

	verify(ut).begin();
	verify(ut).commit();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:JtaTransactionManagerTests.java

示例2: jtaTransactionManagerWithRollbackAndSynchronizationNever

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
@Test
public void jtaTransactionManagerWithRollbackAndSynchronizationNever() throws Exception {
	UserTransaction ut = mock(UserTransaction.class);
	given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE);

	JtaTransactionManager ptm = newJtaTransactionManager(ut);
	TransactionTemplate tt = new TransactionTemplate(ptm);
	ptm.setTransactionSynchronizationName("SYNCHRONIZATION_NEVER");
	tt.setTimeout(10);
	ptm.afterPropertiesSet();

	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
	tt.execute(new TransactionCallbackWithoutResult() {
		@Override
		protected void doInTransactionWithoutResult(TransactionStatus status) {
			assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
			status.setRollbackOnly();
		}
	});
	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());

	verify(ut).setTransactionTimeout(10);
	verify(ut).begin();
	verify(ut, atLeastOnce()).getStatus();
	verify(ut).rollback();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:27,代码来源:JtaTransactionManagerTests.java

示例3: jtaTransactionManagerWithExistingTransactionAndSynchronizationNever

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
@Test
public void jtaTransactionManagerWithExistingTransactionAndSynchronizationNever() throws Exception {
	UserTransaction ut = mock(UserTransaction.class);
	given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);

	JtaTransactionManager ptm = newJtaTransactionManager(ut);
	TransactionTemplate tt = new TransactionTemplate(ptm);
	ptm.setTransactionSynchronization(JtaTransactionManager.SYNCHRONIZATION_NEVER);
	ptm.afterPropertiesSet();

	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
	tt.execute(new TransactionCallbackWithoutResult() {
		@Override
		protected void doInTransactionWithoutResult(TransactionStatus status) {
			assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
			status.setRollbackOnly();
		}
	});
	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());

	verify(ut).setRollbackOnly();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:JtaTransactionManagerTests.java

示例4: jtaTransactionManagerWithPropagationSupportsAndSynchronizationOnActual

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
@Test
public void jtaTransactionManagerWithPropagationSupportsAndSynchronizationOnActual() throws Exception {
	UserTransaction ut = mock(UserTransaction.class);
	given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION);

	JtaTransactionManager ptm = newJtaTransactionManager(ut);
	TransactionTemplate tt = new TransactionTemplate(ptm);
	ptm.setTransactionSynchronization(JtaTransactionManager.SYNCHRONIZATION_ON_ACTUAL_TRANSACTION);
	tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
	ptm.afterPropertiesSet();

	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
	tt.execute(new TransactionCallbackWithoutResult() {
		@Override
		protected void doInTransactionWithoutResult(TransactionStatus status) {
			assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
			status.setRollbackOnly();
		}
	});
	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:JtaTransactionManagerTests.java

示例5: jtaTransactionManagerWithPropagationSupportsAndSynchronizationNever

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
@Test
public void jtaTransactionManagerWithPropagationSupportsAndSynchronizationNever() throws Exception {
	UserTransaction ut = mock(UserTransaction.class);
	given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION);

	JtaTransactionManager ptm = newJtaTransactionManager(ut);
	TransactionTemplate tt = new TransactionTemplate(ptm);
	ptm.setTransactionSynchronization(JtaTransactionManager.SYNCHRONIZATION_NEVER);
	tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
	ptm.afterPropertiesSet();

	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
	tt.execute(new TransactionCallbackWithoutResult() {
		@Override
		protected void doInTransactionWithoutResult(TransactionStatus status) {
			assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
			status.setRollbackOnly();
		}
	});
	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:JtaTransactionManagerTests.java

示例6: testJtaTransactionManagerWithCommitAndSynchronizationNever

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
public void testJtaTransactionManagerWithCommitAndSynchronizationNever() throws Exception {
	UserTransaction ut = mock(UserTransaction.class);
	given(ut.getStatus()).willReturn(
	Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE);

	JtaTransactionManager ptm = newJtaTransactionManager(ut);
	TransactionTemplate tt = new TransactionTemplate(ptm);
	ptm.setTransactionSynchronization(JtaTransactionManager.SYNCHRONIZATION_NEVER);
	ptm.afterPropertiesSet();

	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
	tt.execute(new TransactionCallbackWithoutResult() {
		@Override
		protected void doInTransactionWithoutResult(TransactionStatus status) {
			assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
		}
	});
	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());

	verify(ut).begin();
	verify(ut).commit();
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:23,代码来源:JtaTransactionManagerTests.java

示例7: testJtaTransactionManagerWithRollbackAndSynchronizationNever

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
public void testJtaTransactionManagerWithRollbackAndSynchronizationNever() throws Exception {
	UserTransaction ut = mock(UserTransaction.class);
	given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE);

	JtaTransactionManager ptm = newJtaTransactionManager(ut);
	TransactionTemplate tt = new TransactionTemplate(ptm);
	ptm.setTransactionSynchronizationName("SYNCHRONIZATION_NEVER");
	tt.setTimeout(10);
	ptm.afterPropertiesSet();

	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
	tt.execute(new TransactionCallbackWithoutResult() {
		@Override
		protected void doInTransactionWithoutResult(TransactionStatus status) {
			assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
			status.setRollbackOnly();
		}
	});
	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());

	verify(ut).setTransactionTimeout(10);
	verify(ut).begin();
	verify(ut, atLeastOnce()).getStatus();
	verify(ut).rollback();
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:26,代码来源:JtaTransactionManagerTests.java

示例8: testJtaTransactionManagerWithExistingTransactionAndSynchronizationNever

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
public void testJtaTransactionManagerWithExistingTransactionAndSynchronizationNever() throws Exception {
	UserTransaction ut = mock(UserTransaction.class);
	given(ut.getStatus()).willReturn(Status.STATUS_ACTIVE);

	JtaTransactionManager ptm = newJtaTransactionManager(ut);
	TransactionTemplate tt = new TransactionTemplate(ptm);
	ptm.setTransactionSynchronization(JtaTransactionManager.SYNCHRONIZATION_NEVER);
	ptm.afterPropertiesSet();

	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
	tt.execute(new TransactionCallbackWithoutResult() {
		@Override
		protected void doInTransactionWithoutResult(TransactionStatus status) {
			assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
			status.setRollbackOnly();
		}
	});
	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());

	verify(ut).setRollbackOnly();
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:22,代码来源:JtaTransactionManagerTests.java

示例9: testJtaTransactionManagerWithPropagationSupportsAndSynchronizationOnActual

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
public void testJtaTransactionManagerWithPropagationSupportsAndSynchronizationOnActual() throws Exception {
	UserTransaction ut = mock(UserTransaction.class);
	given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION);

	JtaTransactionManager ptm = newJtaTransactionManager(ut);
	TransactionTemplate tt = new TransactionTemplate(ptm);
	ptm.setTransactionSynchronization(JtaTransactionManager.SYNCHRONIZATION_ON_ACTUAL_TRANSACTION);
	tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
	ptm.afterPropertiesSet();

	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
	tt.execute(new TransactionCallbackWithoutResult() {
		@Override
		protected void doInTransactionWithoutResult(TransactionStatus status) {
			assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
			status.setRollbackOnly();
		}
	});
	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:JtaTransactionManagerTests.java

示例10: testJtaTransactionManagerWithPropagationSupportsAndSynchronizationNever

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
public void testJtaTransactionManagerWithPropagationSupportsAndSynchronizationNever() throws Exception {
	UserTransaction ut = mock(UserTransaction.class);
	given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION);

	JtaTransactionManager ptm = newJtaTransactionManager(ut);
	TransactionTemplate tt = new TransactionTemplate(ptm);
	ptm.setTransactionSynchronization(JtaTransactionManager.SYNCHRONIZATION_NEVER);
	tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
	ptm.afterPropertiesSet();

	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
	tt.execute(new TransactionCallbackWithoutResult() {
		@Override
		protected void doInTransactionWithoutResult(TransactionStatus status) {
			assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
			status.setRollbackOnly();
		}
	});
	assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:JtaTransactionManagerTests.java

示例11: 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

示例12: 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

示例13: jtaTransactionManagerWithCustomJndiLookups

import org.springframework.transaction.jta.JtaTransactionManager; //导入方法依赖的package包/类
@Test
public void jtaTransactionManagerWithCustomJndiLookups() throws Exception {
	UserTransaction ut = mock(UserTransaction.class);
	given(ut.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE, Status.STATUS_ACTIVE);

	TransactionManager tm = mock(TransactionManager.class);

	JtaTransactionManager ptm = new JtaTransactionManager();
	ptm.setUserTransactionName("jndi-ut");
	ptm.setTransactionManagerName("jndi-tm");
	ExpectedLookupTemplate jndiTemplate = new ExpectedLookupTemplate();
	jndiTemplate.addObject("jndi-ut", ut);
	jndiTemplate.addObject("jndi-tm", tm);
	ptm.setJndiTemplate(jndiTemplate);
	ptm.afterPropertiesSet();

	assertEquals(ut, ptm.getUserTransaction());
	assertEquals(tm, ptm.getTransactionManager());

	TransactionTemplate tt = new TransactionTemplate(ptm);
	assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
	assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
	tt.execute(new TransactionCallbackWithoutResult() {
		@Override
		protected void doInTransactionWithoutResult(TransactionStatus status) {
			// something transactional
			assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
			assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
		}
	});
	assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
	assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());

	verify(ut).begin();
	verify(ut).commit();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:37,代码来源:JndiJtaTransactionManagerTests.java

示例14: 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

示例15: 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


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