本文整理汇总了Java中org.alfresco.repo.transaction.AlfrescoTransactionSupport.getTransactionId方法的典型用法代码示例。如果您正苦于以下问题:Java AlfrescoTransactionSupport.getTransactionId方法的具体用法?Java AlfrescoTransactionSupport.getTransactionId怎么用?Java AlfrescoTransactionSupport.getTransactionId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.repo.transaction.AlfrescoTransactionSupport
的用法示例。
在下文中一共展示了AlfrescoTransactionSupport.getTransactionId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: broadcastEvent
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
/**
* Broadcast event.
*
* @param event
* the event
*/
private void broadcastEvent(PropertyBackedBeanEvent event)
{
// If the system is up and running, broadcast the event immediately
if (this.isSchemaAvailable && this.wasDictionaryBootstrapped)
{
// If we have a transaction, the changed properties in it should be updated earlier,
// then the bean restart message will be sent to other node
// see ALF-20066
if (AlfrescoTransactionSupport.getTransactionId() != null &&
(event instanceof PropertyBackedBeanStartedEvent ||
event instanceof PropertyBackedBeanStoppedEvent))
{
this.afterTransactionEvents.add(event);
AlfrescoTransactionSupport.bindListener(this);
}
else
{
for (ApplicationListener listener : this.listeners)
{
listener.onApplicationEvent(event);
}
}
}
// Otherwise, defer broadcasting until the schema available event is handled
else
{
this.deferredEvents.add(event);
}
}
示例2: lockValue
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
@Override
public void lockValue(K keyIn)
{
if (AlfrescoTransactionSupport.getTransactionId() != null)
{
final Serializable key = getTenantAwareCacheKey(keyIn);
TransactionData txnData = getTransactionData();
txnData.lockedItemsCache.add(key);
return;
}
else
{
// No transaction; we can't lock it
return;
}
}
示例3: unlockValue
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
@Override
public void unlockValue(K keyIn)
{
if (AlfrescoTransactionSupport.getTransactionId() != null)
{
final Serializable key = getTenantAwareCacheKey(keyIn);
TransactionData txnData = getTransactionData();
txnData.lockedItemsCache.remove(key);
return;
}
else
{
// No transaction; we can't unlock it
return;
}
}
示例4: beforeCommit
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
@Override
public synchronized void beforeCommit(boolean readOnly)
{
if (txnIdStr == null)
{
txnIdStr = AlfrescoTransactionSupport.getTransactionId();
// Make a change
nodeService.setProperty(rootNodeRef, ContentModel.PROP_COUNTER, new Integer(5));
// Reschedule for removal
AlfrescoTransactionSupport.bindListener(this);
}
else
{
nodeService.removeProperty(rootNodeRef, ContentModel.PROP_COUNTER);
}
lastWriteTime = System.currentTimeMillis();
// We wait a bit so that the time differences are significant
try { this.wait(20L); } catch (InterruptedException e) {}
}
示例5: setUp
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception
{
if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
{
throw new AlfrescoRuntimeException(
"A previous tests did not clean up transaction: " +
AlfrescoTransactionSupport.getTransactionId());
}
transactionService = (TransactionService) ctx.getBean(ServiceRegistry.TRANSACTION_SERVICE.getLocalName());
authorityService = (AuthorityService) ctx.getBean(ServiceRegistry.AUTHORITY_SERVICE.getLocalName());
tenantAdminService = ctx.getBean("tenantAdminService", TenantAdminService.class);
personService = (PersonService) ctx.getBean(ServiceRegistry.PERSON_SERVICE.getLocalName());
tenantService = (TenantService) ctx.getBean("tenantService");
authorityBridgeTableCache = (AuthorityBridgeTableAsynchronouslyRefreshedCache) ctx.getBean("authorityBridgeTableCache");
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:AuthorityBridgeTableAsynchronouslyRefreshedCacheTest.java
示例6: addRepoParameters
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
/**
* Add Repository specific parameters
*
* @param params Map<String, Object>
*/
private void addRepoParameters(Map<String, Object> params)
{
if (AlfrescoTransactionSupport.getTransactionId() != null &&
AuthenticationUtil.getFullAuthentication() != null)
{
NodeRef rootHome = repository.getRootHome();
if (rootHome != null)
{
params.put("roothome", rootHome);
}
NodeRef companyHome = repository.getCompanyHome();
if (companyHome != null)
{
params.put("companyhome", companyHome);
}
NodeRef person = repository.getFullyAuthenticatedPerson();
if (person != null)
{
params.put("person", person);
NodeRef userHome = repository.getUserHome(person);
if (userHome != null)
{
params.put("userhome", userHome);
}
}
}
}
示例7: testTxnCommitTime
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
/**
* <a href="https://issues.alfresco.com/jira/browse/ALF-14929">ALF-14929</a>
*/
public synchronized void testTxnCommitTime() throws Exception
{
// See REPO-2963
if (skipTestRepo2963())
{
return;
}
/*
* This test is subject to intermittent - but correct - failures if bug ALF-14929 is present
*/
String currentTxn = AlfrescoTransactionSupport.getTransactionId();
assertNotNull("Must have a txn change UUID for all transactions.");
long start = System.currentTimeMillis();
this.wait(10L);
// The listener
final TestTxnCommitTimeTxnListener listener = new TestTxnCommitTimeTxnListener();
AlfrescoTransactionSupport.bindListener(listener);
// First see what the latest transaction is
long currentTxnCommitTime = listener.getTxnCommitTime(currentTxn, start);
assertEquals("Should not have found a written txn", 0L, currentTxnCommitTime);
// Now commit
setComplete();
endTransaction();
// Now check again. The transaction time must be greater than the last time that
// the listener wrote through.
long recordedCommitTimeMs = listener.getTxnCommitTime(currentTxn, start);
assertTrue(
"DAO txn write time must be greater than last listener write time",
recordedCommitTimeMs > listener.lastWriteTime);
}
示例8: afterRollback
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
/**
* This will be called if something went wrong. It might have been the lock releases, but
* it could be anything else as well. Each remaining lock is released with warnings where
* it fails.
*/
@Override
public void afterRollback()
{
final String txnId = AlfrescoTransactionSupport.getTransactionId();
final TreeSet<QName> heldLocks = TransactionalResourceHelper.getTreeSet(KEY_RESOURCE_LOCKS);
// Shortcut if there are no locks
if (heldLocks.size() == 0)
{
return;
}
// Clean up any remaining locks
for (final QName lockQName : heldLocks)
{
RetryingTransactionCallback<Object> releaseCallback = new RetryingTransactionCallback<Object>()
{
public Object execute() throws Throwable
{
lockDAO.releaseLock(lockQName, txnId, false);
return null;
}
};
try
{
retryingTransactionHelper.doInTransaction(releaseCallback, false, true);
}
catch (Throwable e)
{
// There is no point propagating this, so just log a warning and
// hope that it expires soon enough
logger.warn(
"Failed to release a lock in 'afterRollback':\n" +
" Lock Name: " + lockQName + "\n" +
" Lock Token: " + txnId,
e);
}
}
}
示例9: getDisableSharedCacheReadForTransaction
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
/**
* @see #setDisableSharedCacheReadForTransaction(boolean)
*/
public boolean getDisableSharedCacheReadForTransaction()
{
if (AlfrescoTransactionSupport.getTransactionId() != null)
{
TransactionData txnData = getTransactionData();
return txnData.noSharedCacheRead;
}
else
{
return false;
}
}
示例10: executeAndCheck
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
private void executeAndCheck(NodeRef nodeRef, RetryingTransactionCallback<Object> callback) throws Throwable
{
UserTransaction txn = txnService.getUserTransaction();
txn.begin();
NodeRef.Status currentStatus = nodeService.getNodeStatus(nodeRef);
assertNotNull(currentStatus);
String currentTxnId = AlfrescoTransactionSupport.getTransactionId();
assertNotNull(currentTxnId);
assertNotSame(currentTxnId, currentStatus.getChangeTxnId());
try
{
callback.execute();
// get the status
NodeRef.Status newStatus = nodeService.getNodeStatus(nodeRef);
assertNotNull(newStatus);
// check
assertEquals("Change didn't update status", currentTxnId, newStatus.getChangeTxnId());
// Make sure we can pre-load the node i.e. nodes in all state need to be pre-loadable
// See CLOUD-1807
Long nodeId = newStatus.getDbId();
nodeDAO.getParentAssocs(nodeId, null, null, null, new DummyChildAssocRefQueryCallback());
nodeDAO.cacheNodesById(Collections.singletonList(nodeId));
txn.commit();
}
catch (Throwable e)
{
try { txn.rollback(); } catch (Throwable ee) {}
throw e;
}
}
示例11: execute
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
@Override
public String execute() throws Throwable
{
nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, GUID.generate());
String txnId = AlfrescoTransactionSupport.getTransactionId();
return txnId;
}
示例12: setUp
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
public void setUp() throws Exception
{
if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
{
throw new AlfrescoRuntimeException(
"A previous tests did not clean up transaction: " +
AlfrescoTransactionSupport.getTransactionId());
}
serviceRegistry = (ServiceRegistry)ctx.getBean("ServiceRegistry");
SimpleCache<String, RepositoryAuthenticationDao.CacheEntry> authenticationCache = (SimpleCache<String, RepositoryAuthenticationDao.CacheEntry>) ctx.getBean("authenticationCache");
SimpleCache<String, NodeRef> immutableSingletonCache = (SimpleCache<String, NodeRef>) ctx.getBean("immutableSingletonCache");
TenantService tenantService = (TenantService) ctx.getBean("tenantService");
compositePasswordEncoder = (CompositePasswordEncoder) ctx.getBean("compositePasswordEncoder");
PolicyComponent policyComponent = (PolicyComponent) ctx.getBean("policyComponent");
repositoryAuthenticationDao = new RepositoryAuthenticationDao();
repositoryAuthenticationDao.setTransactionService(serviceRegistry.getTransactionService());
repositoryAuthenticationDao.setAuthorityService(serviceRegistry.getAuthorityService());
repositoryAuthenticationDao.setTenantService(tenantService);
repositoryAuthenticationDao.setNodeService(serviceRegistry.getNodeService());
repositoryAuthenticationDao.setNamespaceService(serviceRegistry.getNamespaceService());
repositoryAuthenticationDao.setCompositePasswordEncoder(compositePasswordEncoder);
repositoryAuthenticationDao.setPolicyComponent(policyComponent);
repositoryAuthenticationDao.setAuthenticationCache(authenticationCache);
repositoryAuthenticationDao.setSingletonCache(immutableSingletonCache);
upgradePasswordHashWorker = (UpgradePasswordHashWorker)ctx.getBean("upgradePasswordHashWorker");
nodeService = serviceRegistry.getNodeService();
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
}
示例13: setUp
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception
{
if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
{
throw new AlfrescoRuntimeException(
"A previous tests did not clean up transaction: " +
AlfrescoTransactionSupport.getTransactionId());
}
ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry");
transactionService = serviceRegistry.getTransactionService();
retryingTransactionHelper = transactionService.getRetryingTransactionHelper();
retryingTransactionHelper.setMaxRetryWaitMs(10);
nodeService = serviceRegistry.getNodeService();
fileFolderService = serviceRegistry.getFileFolderService();
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
authorityService = (AuthorityService) ctx.getBean("authorityService");
personService = (PersonService) ctx.getBean("personService");
RetryingTransactionCallback<NodeRef> callback = new RetryingTransactionCallback<NodeRef>()
{
public NodeRef execute() throws Throwable
{
// authenticate
authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
// create a test store
StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, getName() + System.currentTimeMillis());
rootNodeRef = nodeService.getRootNode(storeRef);
// create a folder to import into
NodeRef nodeRef = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.ALFRESCO_URI, "working root"),
ContentModel.TYPE_FOLDER).getChildRef();
// Done
return nodeRef;
}
};
workingRootNodeRef = retryingTransactionHelper.doInTransaction(callback, false, true);
}
示例14: TestResult
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
/**
* Construct
*
* @param behaviour String
* @param key1 String
* @param key2 String
* @param arg1 String
* @param arg2 String
*/
public TestResult(String behaviour, String key1, String key2, String arg1, String arg2)
{
this.trxId = AlfrescoTransactionSupport.getTransactionId();
this.behaviour = behaviour;
this.key1 = key1;
this.key2 = key2;
this.arg1 = arg1;
this.arg2 = arg2;
}
示例15: getData
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
/**
* @return Returns the current transaction ID (<tt>null</tt> if not in a transction)
*/
public Serializable getData() throws Throwable
{
return AlfrescoTransactionSupport.getTransactionId();
}