mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Added helper to get transactionally-bound List, Map and Set resources
- Generics allow the following, for instance: Map<NodeRef,List<QName>> filters = TransactionalResourceHelper.getMap(KEY_NODEREF_FILTER); git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13794 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -26,6 +26,7 @@ package org.alfresco.repo.transaction;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
@@ -258,4 +259,23 @@ public class AlfrescoTransactionSupportTest extends TestCase
|
||||
checkTxnReadState = transactionService.getRetryingTransactionHelper().doInTransaction(getReadStateWork, false);
|
||||
assertEquals("Expected 'read-write transaction'", TxnReadState.TXN_READ_WRITE, checkTxnReadState);
|
||||
}
|
||||
|
||||
public void testResourceHelper() throws Exception
|
||||
{
|
||||
// start a transaction
|
||||
RetryingTransactionCallback<Object> testWork = new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object execute() throws Exception
|
||||
{
|
||||
Map<String, String> map = TransactionalResourceHelper.getMap("abc");
|
||||
assertNotNull("Map not created", map);
|
||||
map.put("1", "ONE");
|
||||
Map<String, String> mapCheck = TransactionalResourceHelper.getMap("abc");
|
||||
assertTrue("Same map not retrieved", map == mapCheck);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
// kick it all off
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(testWork);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user