本文整理汇总了Java中org.alfresco.service.transaction.TransactionService.getNonPropagatingUserTransaction方法的典型用法代码示例。如果您正苦于以下问题:Java TransactionService.getNonPropagatingUserTransaction方法的具体用法?Java TransactionService.getNonPropagatingUserTransaction怎么用?Java TransactionService.getNonPropagatingUserTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.transaction.TransactionService
的用法示例。
在下文中一共展示了TransactionService.getNonPropagatingUserTransaction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception
{
ctx = ApplicationContextHelper.getApplicationContext(CONTEXTS);
// Get the required services
transactionService = (TransactionService) ctx.getBean("TransactionService");
subscriptionService = (SubscriptionService) ctx.getBean("SubscriptionService");
personService = (PersonService) ctx.getBean("PersonService");
nodeService = (NodeService) ctx.getBean("NodeService");
searchService = (SearchService) ctx.getBean("SearchService");
repositoryHelper = (Repository) ctx.getBean("repositoryHelper");
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
txn = transactionService.getNonPropagatingUserTransaction(false);
txn.begin();
createPerson(USER_BOB);
createPerson(USER_TOM);
createPerson(USER_LISA);
}
示例2: testTransactionId
import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
public void testTransactionId() throws Exception
{
// get a user transaction
TransactionService transactionService = serviceRegistry.getTransactionService();
UserTransaction txn = transactionService.getUserTransaction();
assertNull("Thread shouldn't have a txn ID", AlfrescoTransactionSupport.getTransactionId());
assertEquals("No transaction start time expected", -1, AlfrescoTransactionSupport.getTransactionStartTime());
// begin the txn
txn.begin();
String txnId = AlfrescoTransactionSupport.getTransactionId();
assertNotNull("Expected thread to have a txn id", txnId);
long txnStartTime = AlfrescoTransactionSupport.getTransactionStartTime();
assertTrue("Expected a transaction start time", txnStartTime > 0);
// check that the txn id and time doesn't change
String txnIdCheck = AlfrescoTransactionSupport.getTransactionId();
assertEquals("Transaction ID changed on same thread", txnId, txnIdCheck);
long txnStartTimeCheck = AlfrescoTransactionSupport.getTransactionStartTime();
assertEquals("Transaction start time changed on same thread", txnStartTime, txnStartTimeCheck);
// begin a new, inner transaction
{
UserTransaction txnInner = transactionService.getNonPropagatingUserTransaction();
String txnIdInner = AlfrescoTransactionSupport.getTransactionId();
assertEquals("Inner transaction not started, so txn ID should not change", txnId, txnIdInner);
long txnStartTimeInner = AlfrescoTransactionSupport.getTransactionStartTime();
assertEquals("Inner transaction not started, so txn start time should not change", txnStartTime, txnStartTimeInner);
// begin the nested txn
txnInner.begin();
// check the ID for the outer transaction
txnIdInner = AlfrescoTransactionSupport.getTransactionId();
assertNotSame("Inner txn ID must be different from outer txn ID", txnIdInner, txnId);
// Check the time against the outer transaction
txnStartTimeInner = AlfrescoTransactionSupport.getTransactionStartTime();
assertTrue(
"Inner transaction start time should be greater or equal (accuracy) to the outer's",
txnStartTime <= txnStartTimeInner);
// rollback the nested txn
txnInner.rollback();
txnIdCheck = AlfrescoTransactionSupport.getTransactionId();
assertEquals("Txn ID not popped inner txn completion", txnId, txnIdCheck);
}
// rollback
txn.rollback();
assertNull("Thread shouldn't have a txn ID after rollback", AlfrescoTransactionSupport.getTransactionId());
// start a new transaction
txn = transactionService.getUserTransaction();
txn.begin();
txnIdCheck = AlfrescoTransactionSupport.getTransactionId();
assertNotSame("New transaction has same ID", txnId, txnIdCheck);
// rollback
txn.rollback();
assertNull("Thread shouldn't have a txn ID after rollback", AlfrescoTransactionSupport.getTransactionId());
}