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


Java TransactionService.getNonPropagatingUserTransaction方法代码示例

本文整理汇总了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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:SubscriptionServiceImplTest.java

示例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());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:62,代码来源:AlfrescoTransactionSupportTest.java


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