本文整理汇总了Java中org.alfresco.service.transaction.TransactionService.getRetryingTransactionHelper方法的典型用法代码示例。如果您正苦于以下问题:Java TransactionService.getRetryingTransactionHelper方法的具体用法?Java TransactionService.getRetryingTransactionHelper怎么用?Java TransactionService.getRetryingTransactionHelper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.transaction.TransactionService
的用法示例。
在下文中一共展示了TransactionService.getRetryingTransactionHelper方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initContextAndCreateUser
import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
public void initContextAndCreateUser()
{
appContext = ApplicationContextHelper.getApplicationContext();
authenticationService = (MutableAuthenticationService) appContext.getBean("AuthenticationService");
contentService = (ContentService) appContext.getBean("ContentService");
nodeService = (NodeService) appContext.getBean("NodeService");
permissionService = (PermissionService) appContext.getBean("PermissionService");
personService = (PersonService) appContext.getBean("PersonService");
renditionService = (RenditionService) appContext.getBean("RenditionService");
repositoryHelper = (Repository) appContext.getBean("repositoryHelper");
transactionService = (TransactionService) appContext.getBean("TransactionService");
txnHelper = transactionService.getRetryingTransactionHelper();
ownableService = (OwnableService) appContext.getBean("ownableService");
ADMIN_USER = AuthenticationUtil.getAdminUserName();
// Create a nonAdminUser
createUser(NON_ADMIN_USER);
}
示例2: setTransactionService
import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
/**
* Set the transaction provider so that each execution can be performed within a transaction
*/
public void setTransactionService(TransactionService transactionService)
{
this.transactionService = transactionService;
this.transactionHelper = transactionService.getRetryingTransactionHelper();
this.transactionHelper.setForceWritable(true);
}
示例3: setUp
import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void setUp() throws Exception
{
ConfigurableApplicationContext appContext = loadContext();
this.repo = (RepositoryService) appContext.getBean("activitiRepositoryService");
this.runtime = (RuntimeService) appContext.getBean("activitiRuntimeService");
ServiceRegistry serviceRegistry = (ServiceRegistry) appContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
authenticationComponent = (AuthenticationComponent) appContext.getBean("authenticationComponent");
TransactionService transactionService = serviceRegistry.getTransactionService();
nodeService = serviceRegistry.getNodeService();
txnHelper = transactionService.getRetryingTransactionHelper();
// authenticate
authenticationComponent.setSystemUserAsCurrentUser();
StoreRef storeRef = nodeService.createStore(
StoreRef.PROTOCOL_WORKSPACE,
"test-" + getName() + "-" + System.currentTimeMillis());
NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
// Create a node to work on
workingNodeRef = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, getName()),
ContentModel.TYPE_CMOBJECT).getChildRef();
String resource = "org/alfresco/repo/workflow/activiti/testTransaction.bpmn20.xml";
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream input= classLoader.getResourceAsStream(resource);
this.deployment = repo.createDeployment()
.addInputStream(resource, input)
.deploy();
}
示例4: setUp
import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void setUp() throws Exception
{
ApplicationContext appContext = ApplicationContextHelper.getApplicationContext();
this.repo = (RepositoryService) appContext.getBean("activitiRepositoryService");
this.runtime = (RuntimeService) appContext.getBean("activitiRuntimeService");
ServiceRegistry serviceRegistry = (ServiceRegistry) appContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
authenticationComponent = (AuthenticationComponent) appContext.getBean("authenticationComponent");
TransactionService transactionService = serviceRegistry.getTransactionService();
nodeService = serviceRegistry.getNodeService();
txnHelper = transactionService.getRetryingTransactionHelper();
// authenticate
authenticationComponent.setSystemUserAsCurrentUser();
StoreRef storeRef = nodeService.createStore(
StoreRef.PROTOCOL_WORKSPACE,
"test-" + getName() + "-" + System.currentTimeMillis());
NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
// Create a node to work on
workingNodeRef = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, getName()),
ContentModel.TYPE_CMOBJECT).getChildRef();
String resource = "activiti/testTransaction.bpmn20.xml";
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream input= classLoader.getResourceAsStream(resource);
this.deployment = repo.createDeployment()
.addInputStream(resource, input)
.deploy();
}
示例5: setUp
import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception
{
transactionService = (TransactionService) ctx.getBean("TransactionService");
txnHelper = transactionService.getRetryingTransactionHelper();
txnHelper.setMaxRetries(0);
propertyValueDAO = (PropertyValueDAO) ctx.getBean("propertyValueDAO");
// Remove the caches to test all functionality
removeCaches();
}
示例6: setUp
import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception
{
transactionService = (TransactionService)ctx.getBean("transactionService");
txnHelper = transactionService.getRetryingTransactionHelper();
usageDAO = (UsageDAO)ctx.getBean("usageDAO");
nodeDAO = (NodeDAO)ctx.getBean("nodeDAO");
}
示例7: getRetryingTransactionHelper
import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
@Override
public RetryingTransactionHelper getRetryingTransactionHelper()
{
TransactionService txnService = (TransactionService) getService(TRANSACTION_SERVICE);
return txnService.getRetryingTransactionHelper();
}
示例8: setTransactionService
import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
/**
* Set the transaction provider so that each execution can be performed within a transaction
*/
public void setTransactionService(TransactionService transactionService)
{
this.transactionService = transactionService;
this.transactionHelper = transactionService.getRetryingTransactionHelper();
}
示例9: setUp
import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception
{
applicationContext = ApplicationContextHelper.getApplicationContext();
repositoryHelper = (Repository)this.applicationContext.getBean("repositoryHelper");
ApplicationContextFactory fileServers = (ApplicationContextFactory) this.applicationContext.getBean("fileServers");
cifsHelper = (CifsHelper) fileServers.getApplicationContext().getBean("cifsHelper");
driver = (ExtendedDiskInterface)this.applicationContext.getBean("contentDiskDriver");
mlAwareNodeService = (NodeService) this.applicationContext.getBean("mlAwareNodeService");
nodeService = (NodeService)applicationContext.getBean("nodeService");
transactionService = (TransactionService)applicationContext.getBean("transactionService");
contentService = (ContentService)applicationContext.getBean("contentService");
ruleService = (RuleService)applicationContext.getBean("ruleService");
actionService = (ActionService)this.applicationContext.getBean("actionService");
personService = (PersonService) this.applicationContext.getBean("personService");
authenticationService = (MutableAuthenticationService) this.applicationContext.getBean("authenticationService");
permissionService = (PermissionService) this.applicationContext.getBean("permissionService");
ownableService = (OwnableService) this.applicationContext.getBean("ownableService");
fileFolderService = (FileFolderService) this.applicationContext.getBean("fileFolderService");
checkOutCheckInService = (CheckOutCheckInService) this.applicationContext.getBean("checkOutCheckInService");
assertNotNull("content disk driver is null", driver);
assertNotNull("repositoryHelper is null", repositoryHelper);
assertNotNull("mlAwareNodeService is null", mlAwareNodeService);
assertNotNull("nodeService is null", nodeService);
assertNotNull("transactionService is null", transactionService);
assertNotNull("contentService is null", contentService);
assertNotNull("ruleService is null", ruleService);
assertNotNull("actionService is null", actionService);
assertNotNull("cifsHelper", cifsHelper);
assertNotNull("checkOutCheckInService", checkOutCheckInService);
AuthenticationUtil.setRunAsUserSystem();
// remove our test root
RetryingTransactionCallback<Void> removeRootCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable
{
NodeRef companyHome = repositoryHelper.getCompanyHome();
NodeRef rootNode = nodeService.getChildByName(companyHome, ContentModel.ASSOC_CONTAINS, TEST_ROOT_PATH);
if(rootNode != null)
{
logger.debug("Clean up test root node");
nodeService.deleteNode(rootNode);
}
return null;
}
};
final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();
tran.doInTransaction(removeRootCB, false, true);
}
示例10: setUp
import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception
{
applicationContext = ApplicationContextHelper.getApplicationContext();
nodeService = (NodeService)applicationContext.getBean("nodeService");
personService = (PersonService)applicationContext.getBean("personService");
authenticationService = (MutableAuthenticationService)applicationContext.getBean("AuthenticationService");
authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
transactionService = (TransactionService)applicationContext.getBean("transactionService");
repositoryHelper = (Repository)applicationContext.getBean("repositoryHelper");
permissionService = (PermissionService)applicationContext.getBean("permissionService");
ServerConfigurationAccessor fileServerConfiguration = (ServerConfigurationAccessor)applicationContext.getBean("fileServerConfiguration");
ftpConfigSection = (FTPConfigSection) fileServerConfiguration.getConfigSection( FTPConfigSection.SectionName);
assertNotNull("nodeService is null", nodeService);
assertNotNull("reporitoryHelper is null", repositoryHelper);
assertNotNull("personService is null", personService);
assertNotNull("authenticationService is null", authenticationService);
assertNotNull("authenticationComponent is null", authenticationComponent);
authenticationComponent.setSystemUserAsCurrentUser();
final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();
RetryingTransactionCallback<Void> createUsersCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable
{
createUser(USER_ONE, PASSWORD_ONE, -1);
createUser(USER_TWO, PASSWORD_TWO, -1);
createUser(USER_THREE, PASSWORD_THREE, 30);
return null;
}
};
tran.doInTransaction(createUsersCB);
RetryingTransactionCallback<Void> createTestDirCB = new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable
{
{
NodeRef userOneHome = repositoryHelper.getUserHome(personService.getPerson(USER_ONE));
permissionService.setPermission(userOneHome, USER_TWO, PermissionService.CONTRIBUTOR, true);
permissionService.setPermission(userOneHome, USER_TWO, PermissionService.WRITE, true);
}
return null;
}
};
tran.doInTransaction(createTestDirCB, false, true);
}
示例11: testRollbackCleanup
import org.alfresco.service.transaction.TransactionService; //导入方法依赖的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));
}