當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。