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


Java RetryingTransactionHelper.doInTransaction方法代码示例

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


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

示例1: before

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
/**
 * Create the tenant.
 */
@Override protected void before() throws Throwable
{
    final ApplicationContext appCtx = getApplicationContext();
    RetryingTransactionHelper transactionHelper = appCtx.getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
	final TenantAdminService tenantAdminService = appCtx.getBean("tenantAdminService", TenantAdminService.class);
    
    transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>()
    {
        @Override public Void execute() throws Throwable
        {
        	tenantAdminService.createTenant(tenantName, ADMIN_PASSWORD.toCharArray());
        	return null;
        }

    });
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:AlfrescoTenant.java

示例2: testImportArchiveWithSuspiciousPaths

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
@Test
public void testImportArchiveWithSuspiciousPaths() throws IOException
{
    final RetryingTransactionHelper retryingTransactionHelper = serviceRegistry.getRetryingTransactionHelper();

    retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<Void>()
    {
        public Void execute()
        {
            NodeRef rootNodeRef = nodeService.getRootNode(storeRef);

            NodeRef zipFileNodeRef = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN,
                    QName.createQName("http://www.alfresco.org/test/ImporterActionExecuterTest", "testAssocQName1"), ContentModel.TYPE_CONTENT).getChildRef();

            NodeRef targetFolderNodeRef = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN,
                    QName.createQName("http://www.alfresco.org/test/ImporterActionExecuterTest", "testAssocQName2"), ContentModel.TYPE_FOLDER).getChildRef();

            putContent(zipFileNodeRef, FILE_NAME);

            Action action = createAction(zipFileNodeRef, "ImporterActionExecuterTestActionDefinition", targetFolderNodeRef);

            try
            {
                importerActionExecuter.execute(action, zipFileNodeRef);
                fail("An AlfrescoRuntimeException should have occured.");
            }
            catch (AlfrescoRuntimeException e)
            {
                assertTrue(e.getMessage().contains(ImporterActionExecuter.ARCHIVE_CONTAINS_SUSPICIOUS_PATHS_ERROR));
            }
            finally
            {
                nodeService.deleteNode(targetFolderNodeRef);
                nodeService.deleteNode(zipFileNodeRef);
            }

            return null;
        }
    });
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:41,代码来源:ImporterActionExecuterTest.java

示例3: getNextWork

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
@Override
public synchronized Collection<NodeRef> getNextWork()
{
    if (vmShutdownLister.isVmShuttingDown())
    {
        return Collections.emptyList();
    }

    RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
    RetryingTransactionCallback<Collection<NodeRef>> restoreCallback = new RetryingTransactionCallback<Collection<NodeRef>>()
    {
        public Collection<NodeRef> execute() throws Exception
        {
            Collection<NodeRef> results = new ArrayList<NodeRef>(BATCH_SIZE);
            while (results.size() < BATCH_SIZE && iterator.hasNext())
            {
                String userName = iterator.next();
                try
                {
                    NodeRef person = personService.getPerson(userName, false);
                    results.add(person);
                }
                catch (NoSuchPersonException e)
                {
                    if (logger.isTraceEnabled())
                    {
                        logger.trace("The user "+userName+" no longer exists - ignored.");
                    }
                }
            }
            return results;
        }
    };
    return txnHelper.doInTransaction(restoreCallback, false, true);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:36,代码来源:HomeFolderProviderSynchronizer.java

示例4: deleteNodeByNodeRef

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
public void deleteNodeByNodeRef(final String nodeRef)
{
    RetryingTransactionHelper txHelper = transactionService.getRetryingTransactionHelper();

    txHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
        {
            public Void execute() throws Throwable
            {
                fileTransferInfoDAO.deleteFileTransferInfoByNodeRef(nodeRef);
                return null;
            }
        }, false, false);
}
 
开发者ID:Alfresco,项目名称:alfresco-file-transfer-receiver,代码行数:14,代码来源:DbHelperImpl.java

示例5: createNodeWithTextContent

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
/**
 * This method creates a NodeRef with some text/plain, UTF-8 content and adds it to the internal list of NodeRefs to be tidied up by the rule.
 * This method will be run in its own transaction and will be run with the specified user as the fully authenticated user,
 * thus ensuring the named user is the cm:creator of the new node.
 * 
 * @param parentNode the parent node
 * @param nodeCmName the cm:name of the new node
 * @param nodeType   the type of the new node
 * @param nodeCreator the username of the person who will create the node
 * @param textContent the text/plain, UTF-8 content that will be stored in the node's content. <code>null</code> content will not be written.
 * @return the newly created NodeRef.
 */
public NodeRef createNodeWithTextContent(final NodeRef parentNode, final QName childName, final String nodeCmName, final QName nodeType, final String nodeCreator, final String textContent)
{
    final RetryingTransactionHelper transactionHelper = (RetryingTransactionHelper) appContextRule.getApplicationContext().getBean("retryingTransactionHelper");
    
    AuthenticationUtil.pushAuthentication();
    AuthenticationUtil.setFullyAuthenticatedUser(nodeCreator);
    
    NodeRef newNodeRef = transactionHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
    {
        public NodeRef execute() throws Throwable
        {
            final NodeService nodeService = (NodeService) appContextRule.getApplicationContext().getBean("nodeService");
            
            Map<QName, Serializable> props = new HashMap<QName, Serializable>();
            props.put(ContentModel.PROP_NAME, nodeCmName);
            ChildAssociationRef childAssoc = nodeService.createNode(parentNode,
                        ContentModel.ASSOC_CONTAINS,
                        childName,
                        nodeType,
                        props);
            
            // If there is any content, add it.
            if (textContent != null)
            {
                ContentService contentService = appContextRule.getApplicationContext().getBean("contentService", ContentService.class);
                ContentWriter writer = contentService.getWriter(childAssoc.getChildRef(), ContentModel.PROP_CONTENT, true);
                writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
                writer.setEncoding("UTF-8");
                writer.putContent(textContent);
            }
            return childAssoc.getChildRef();
        }
    });
    
    AuthenticationUtil.popAuthentication();
    
    this.temporaryNodeRefs.add(newNodeRef);
    return newNodeRef;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:52,代码来源:TemporaryNodes.java

示例6: createQuickFile

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
/**
 * This method creates a cm:content NodeRef whose content is taken from an Alfresco 'quick' file and adds it to the internal
 * list of NodeRefs to be tidied up by the rule.
 * This method will be run in its own transaction and will be run with the specified user as the fully authenticated user,
 * thus ensuring the named user is the cm:creator of the new node.
 * 
 * @param mimetype the MimeType of the content to put in the new node.
 * @param parentNode the parent node
 * @param nodeCmName the cm:name of the new node
 * @param nodeCreator the username of the person who will create the node
 * @param isVersionable should the new node be {@link ContentModel#ASPECT_VERSIONABLE versionable}?
 * @return the newly created NodeRef.
 */
public NodeRef createQuickFile(final String mimetype, final NodeRef parentNode, final String nodeCmName, final String nodeCreator, final boolean isVersionable)
{
    final RetryingTransactionHelper transactionHelper = (RetryingTransactionHelper) appContextRule.getApplicationContext().getBean("retryingTransactionHelper");
    
    AuthenticationUtil.pushAuthentication();
    AuthenticationUtil.setFullyAuthenticatedUser(nodeCreator);
    
    NodeRef newNodeRef = transactionHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
    {
        public NodeRef execute() throws Throwable
        {
            final NodeRef result = createNode(nodeCmName, parentNode, ContentModel.TYPE_CONTENT);
            
            if (isVersionable)
            {
                NodeService nodeService = appContextRule.getApplicationContext().getBean("nodeService", NodeService.class);
                nodeService.addAspect(result, ContentModel.ASPECT_VERSIONABLE, null);
            }
            
            File quickFile = AbstractContentTransformerTest.loadNamedQuickTestFile(getQuickResource(mimetype));
            
            ContentService contentService = appContextRule.getApplicationContext().getBean("contentService", ContentService.class);
            ContentWriter writer = contentService.getWriter(result, ContentModel.PROP_CONTENT, true);
            writer.setMimetype(mimetype);
            writer.setEncoding("UTF-8");
            writer.putContent(quickFile);
            
            return result;
        }
    });
    
    AuthenticationUtil.popAuthentication();
    
    this.temporaryNodeRefs.add(newNodeRef);
    return newNodeRef;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:50,代码来源:TemporaryNodes.java

示例7: updateFileTransferInfoByNodeRef

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
public void updateFileTransferInfoByNodeRef(final FileTransferInfoEntity modifiedEntity)
{
    RetryingTransactionHelper txHelper = transactionService.getRetryingTransactionHelper();

    txHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
        {
            public Void execute() throws Throwable
            {
                fileTransferInfoDAO.updateFileTransferInfoByNodeRef(modifiedEntity);
                return null;
            }
        }, false, false);
}
 
开发者ID:Alfresco,项目名称:alfresco-file-transfer-receiver,代码行数:14,代码来源:DbHelperImpl.java

示例8: resolveVirtualFolderDefinition

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
public VirtualFolderDefinition resolveVirtualFolderDefinition(final Reference reference)
            throws VirtualizationException
{
    ServiceRegistry serviceRegistry = ((AlfrescoEnviroment) environment).getServiceRegistry();
    RetryingTransactionHelper transactionHelper = serviceRegistry.getRetryingTransactionHelper();

    return transactionHelper.doInTransaction(new RetryingTransactionCallback<VirtualFolderDefinition>()
                                             {

                                                 @Override
                                                 public VirtualFolderDefinition execute() throws Throwable
                                                 {
                                                     NodeRef key = reference.toNodeRef();

                                                     Map<NodeRef, VirtualFolderDefinition> definitionsCache = TransactionalResourceHelper
                                                                 .getMap(VIRTUAL_FOLDER_DEFINITION);

                                                     VirtualFolderDefinition virtualFolderDefinition = definitionsCache
                                                                 .get(key);

                                                     if (virtualFolderDefinition == null)
                                                     {

                                                         virtualFolderDefinition = reference
                                                                     .execute(new ApplyTemplateMethod(environment));
                                                         definitionsCache.put(key,
                                                                              virtualFolderDefinition);
                                                     }

                                                     return virtualFolderDefinition;
                                                 }
                                             },
                                             true,
                                             false);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:36,代码来源:VirtualStoreImpl.java

示例9: before

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
@Override protected void before()
{
    ApplicationContext ctxt = getApplicationContext();
    RetryingTransactionHelper transactionHelper = (RetryingTransactionHelper) ctxt.getBean("retryingTransactionHelper");
    
    transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>()
    {
        @Override public Void execute() throws Throwable
        {
            personNodeRef = createPerson(userName);
            
            return null;
        }
    });
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:16,代码来源:AlfrescoPerson.java

示例10: doTransactionWorkAsEditor

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
private void doTransactionWorkAsEditor(final RunAsWork<Void> work, RetryingTransactionHelper tran)
{
    RetryingTransactionCallback<Void> transactionCallback = new RetryingTransactionCallback<Void>()
    {
        @Override
        public Void execute() throws Throwable
        {
            try
            {
                AuthenticationUtil.runAs(work, ContentDiskDriverTest.TEST_USER_AUTHORITY);
            }
            catch (Exception e)
            {
                // Informing about test failure. Expected exception is 'AccessDeniedException' or 'PermissionDeniedException'
                if (e.getCause() instanceof AccessDeniedException || e.getCause() instanceof PermissionDeniedException)
                {
                    fail("For user='" + TEST_USER_AUTHORITY + "' " + e.getCause().toString());
                }
                else
                {
                    fail("Unexpected exception was caught: " + e.toString());
                }
            }
            return null;
        }
    };
    tran.doInTransaction(transactionCallback, false, true);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:29,代码来源:ContentDiskDriverTest.java

示例11: isContentNewOrModified

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
public boolean isContentNewOrModified(final String nodeRef, final String contentUrl)
{
    RetryingTransactionHelper txHelper = transactionService.getRetryingTransactionHelper();

    return txHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Boolean>()
    {
        public Boolean execute() throws Throwable
        {
            if (log.isDebugEnabled())
            {
                log.debug("Checking content for node " + nodeRef);
                log.debug("Supplied content URL is " + contentUrl);
            }
            boolean result = false;
            FileTransferInfoEntity fileTransferInfoEntity = fileTransferInfoDAO
                    .findFileTransferInfoByNodeRef(nodeRef);
            if (fileTransferInfoEntity == null)
            {
                result = true;
                if (log.isDebugEnabled())
                {
                    log.debug("No record found for this node");
                }
            }
            else if (contentUrl != null && !contentUrl.equals(fileTransferInfoEntity.getContentUrl()))
            {
                result = true;
                if (log.isDebugEnabled())
                {
                    log.debug("Supplied content URL is different to the one on record: " + 
                            fileTransferInfoEntity.getContentUrl());
                }
            }
            else
            {
                if (log.isDebugEnabled())
                {
                    log.debug("Content URL has not changed");
                }
            }
            return result;
        }
    }, true, false);
}
 
开发者ID:Alfresco,项目名称:alfresco-file-transfer-receiver,代码行数:45,代码来源:FileTransferReceiver.java

示例12: createTestSiteWithUserPerRole

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
/**
 * This method creates a test site (of Alfresco type <code>st:site</code>) and one user for each of the Share Site Roles.
 * This method will be run in its own transaction and will be run with the specified user as the fully authenticated user,
 * thus ensuring the named user is the creator of the new site.
 * The site and its users will be deleted automatically by the rule.
 * 
 * @param sitePreset the site preset.
 * @param visibility the Site visibility.
 * @param siteCreator the username of a user who will be used to create the site (user must exist of course).
 * @return the {@link SiteInfo} object for the newly created site.
 */
public TestSiteAndMemberInfo createTestSiteWithUserPerRole(final String siteShortName, String sitePreset, SiteVisibility visibility, String siteCreator)
{
    // create the site
    SiteInfo result = this.createSite(sitePreset, siteShortName, null, null, visibility, siteCreator);
    
    // create the users
    final RetryingTransactionHelper transactionHelper = appContextRule.getApplicationContext().getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
    final SiteService siteService = appContextRule.getApplicationContext().getBean("siteService", SiteService.class);
    
    AuthenticationUtil.pushAuthentication();
    AuthenticationUtil.setFullyAuthenticatedUser(siteCreator);
    
    // Create users for this test site that cover the various roles.
    List<String> userNames = transactionHelper.doInTransaction(new RetryingTransactionCallback<List<String>>()
    {
        public List<String> execute() throws Throwable
        {
            List<String> users = new ArrayList<String>(4);
            
            for (String shareRole : SiteModel.STANDARD_PERMISSIONS)
            {
                final String userName = siteShortName + "_" + shareRole + "_" + GUID.generate();
                
                log.debug("Creating temporary site user " + userName);
                
                createPerson(userName);
                siteService.setMembership(siteShortName, userName, shareRole);
                users.add(userName);
                
                temporarySiteUsers.add(userName);
            }
            
            return users;
        }
    });
    
    NodeRef doclibFolder = transactionHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
    {
        public NodeRef execute() throws Throwable
        {
            return siteService.getContainer(siteShortName, SiteService.DOCUMENT_LIBRARY);
        }
    });
    
    AuthenticationUtil.popAuthentication();
     
    
    return new TestSiteAndMemberInfo(result, doclibFolder, userNames.get(0),
                                                           userNames.get(1),
                                                           userNames.get(2),
                                                           userNames.get(3));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:64,代码来源:TemporarySites.java

示例13: testFileExists

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
/**
 * Unit test of file exists
 */
public void testFileExists() throws Exception
{
    logger.debug("testFileExists");
    ServerConfiguration scfg = new ServerConfiguration("testServer");
    TestServer testServer = new TestServer("testServer", scfg);
    final SrvSession testSession = new TestSrvSession(666, testServer, "test", "remoteName");
    DiskSharedDevice share = getDiskSharedDevice();
    final TreeConnection testConnection = testServer.getTreeConnection(share);
    final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();
    
    final String FILE_PATH= TEST_ROOT_DOS_PATH + "\\testFileExists.new";
    
    class TestContext
    {
    };
    
    final TestContext testContext = new TestContext();
   
    /**
     * Step 1 : Call FileExists for a directory which does not exist
     */
    logger.debug("Step 1, negative test dir does not exist");
    int status = driver.fileExists(testSession, testConnection, TEST_ROOT_DOS_PATH);
    assertEquals(status, 0);
  
    /**
     * Step 2 : Call FileExists for a file which does not exist
     */
    logger.debug("Step 2, negative test file does not exist");
    status = driver.fileExists(testSession, testConnection, FILE_PATH);
    assertEquals(status, 0);
    
    /**
     * Step 3: Create a new file in read/write mode and add some content.
     */
    int openAction = FileAction.CreateNotExist;

    FileOpenParams params = new FileOpenParams(FILE_PATH, openAction, AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
    FileOpenParams dirParams = new FileOpenParams(TEST_ROOT_DOS_PATH, 0, AccessMode.ReadOnly, FileAttribute.NTDirectory, 0);
 
    driver.createDirectory(testSession, testConnection, dirParams);        
    final NetworkFile file = driver.createFile(testSession, testConnection, params);
    assertNotNull("file is null", file);
    assertFalse("file is read only, should be read-write", file.isReadOnly());
    
    RetryingTransactionCallback<Void> createFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable
        {
            byte[] stuff = "Hello World".getBytes();
            file.writeFile(stuff, stuff.length, 0, 0);
            driver.closeFile(testSession, testConnection, file);
        
            return null;
        }
    };
    tran.doInTransaction(createFileCB, false, true);
     
    status = driver.fileExists(testSession, testConnection, FILE_PATH);
    assertEquals(status, 1);
     
    /**
      * Step 4 : Delete the node - check status goes back to 0
      */
    logger.debug("Step 4, successfully delete node");
    driver.deleteFile(testSession, testConnection, FILE_PATH);
    
    status = driver.fileExists(testSession, testConnection, FILE_PATH);
    assertEquals(status, 0);  
   
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:76,代码来源:ContentDiskDriverTest.java

示例14: deleteContentStream

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
@Override
    public void deleteContentStream(
            String repositoryId, Holder<String> objectId, Holder<String> changeToken,
            ExtensionsData extension)
    {
        checkRepositoryId(repositoryId);

        CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");

        if (!info.isVariant(CMISObjectVariant.CURRENT_VERSION) && !info.isVariant(CMISObjectVariant.PWC))
        {
            throw new CmisStreamNotSupportedException("Content can only be deleted from ondocuments!");
        }

        final NodeRef nodeRef = info.getNodeRef();

        if (((DocumentTypeDefinition) info.getType().getTypeDefinition(false)).getContentStreamAllowed() == ContentStreamAllowed.REQUIRED)
        {
            throw new CmisInvalidArgumentException("Document type requires content!");
        }

        //ALF-21852 - Separated deleteContent and objectId.setValue in two different transactions because
        //after executing deleteContent, the new objectId is not visible.
        RetryingTransactionHelper helper = connector.getRetryingTransactionHelper();
        helper.doInTransaction(new RetryingTransactionCallback<Void>()
        {
            public Void execute() throws Throwable
            {

                connector.getNodeService().setProperty(nodeRef, ContentModel.PROP_CONTENT, null);

//              connector.createVersion(nodeRef, VersionType.MINOR, "Delete content");

                connector.getActivityPoster().postFileFolderUpdated(info.isFolder(), nodeRef);
                return null;
            }
        }, false, true);

        String objId = helper.doInTransaction(new RetryingTransactionCallback<String>()
        {
            public String execute() throws Throwable
            {
                return connector.createObjectId(nodeRef);
            }
        }, true, true);

        objectId.setValue(objId);
    }
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:49,代码来源:AlfrescoCmisServiceImpl.java

示例15: testRollbackCleanup

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
public void testRollbackCleanup() throws Exception
{
    TransactionService transactionService = serviceRegistry.getTransactionService();
    RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();

    // Add items to the global cache
    TransactionalCache.putSharedCacheValue(backingCache, NEW_GLOBAL_ONE, NEW_GLOBAL_ONE, null);
    
    RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
    {
        private int throwCount = 0;
        public Object execute() throws Throwable
        {
            transactionalCache.put(NEW_GLOBAL_TWO, NEW_GLOBAL_TWO);
            transactionalCache.remove(NEW_GLOBAL_ONE);

            String key = "B";
            String value = "BBB";
            // no transaction - do a put
            transactionalCache.put(key, value);
            // Blow up
            if (throwCount < 5)
            {
                throwCount++;
                throw new SQLException("Dummy");
            }
            else
            {
                throw new Exception("Fail");
            }
        }
    };
    try
    {
        txnHelper.doInTransaction(callback);
    }
    catch (Exception e)
    {
        // Expected
    }
    
    assertFalse("Remove not done after rollback", transactionalCache.contains(NEW_GLOBAL_ONE));
    assertFalse("Update happened after rollback", transactionalCache.contains(NEW_GLOBAL_TWO));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:45,代码来源:CacheTest.java


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