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:
Derek Hulley
2009-04-01 13:17:52 +00:00
parent b83115a62c
commit e7d9ce8fc6
3 changed files with 122 additions and 2 deletions

View File

@@ -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);
}
}