More for AR-460: System concurrency

There might be a few SDK projects that still use TransactionUtil, but this checkin gets rid of
its use otherwise.
I took a glance over the areas of the code that use UserTransaction directly and didn't see any
transactionally wrapped code that desperately needed to be put into a retry loop (i.e. write
transactions in a concurrent scenario).  If you spot any that you think might qualify, let me know.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6220 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-07-12 04:15:28 +00:00
parent 32054c773c
commit 0d1bd57217
31 changed files with 230 additions and 286 deletions

View File

@@ -31,8 +31,7 @@ import java.util.Properties;
import org.alfresco.repo.importer.ImporterBootstrap; import org.alfresco.repo.importer.ImporterBootstrap;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao; import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
@@ -72,9 +71,9 @@ public class TestData
{ {
final ServiceRegistry serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); final ServiceRegistry serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
TransactionService transactionService = serviceRegistry.getTransactionService(); TransactionService transactionService = serviceRegistry.getTransactionService();
TransactionWork<Object> createUserWork = new TransactionWork<Object>() RetryingTransactionCallback<Object> createUserWork = new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// Bootstrap Users // Bootstrap Users
MutableAuthenticationDao authDAO = (MutableAuthenticationDao) applicationContext.getBean("alfDaoImpl"); MutableAuthenticationDao authDAO = (MutableAuthenticationDao) applicationContext.getBean("alfDaoImpl");
@@ -93,7 +92,7 @@ public class TestData
return null; return null;
} }
}; };
TransactionUtil.executeInUserTransaction(transactionService, createUserWork); transactionService.getRetryingTransactionHelper().doInTransaction(createUserWork);
try try
{ {

View File

@@ -42,7 +42,7 @@ import org.alfresco.repo.action.executer.CompositeActionExecuter;
import org.alfresco.repo.action.executer.MoveActionExecuter; import org.alfresco.repo.action.executer.MoveActionExecuter;
import org.alfresco.repo.action.executer.ScriptActionExecuter; import org.alfresco.repo.action.executer.ScriptActionExecuter;
import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionCondition; import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ActionConditionDefinition; import org.alfresco.service.cmr.action.ActionConditionDefinition;
@@ -810,11 +810,10 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest
// Sleep for a bit // Sleep for a bit
Thread.sleep(sleepTime); Thread.sleep(sleepTime);
done = (TransactionUtil.executeInUserTransaction( done = (transactionService.getRetryingTransactionHelper().doInTransaction(
transactionService, new RetryingTransactionCallback<Boolean>()
new TransactionUtil.TransactionWork<Boolean>()
{ {
public Boolean doWork() public Boolean execute()
{ {
// See if the action has been performed // See if the action has been performed
boolean done = test.executeTest(); boolean done = test.executeTest();
@@ -947,11 +946,10 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest
// Modify the compensating action so that it will also fail // Modify the compensating action so that it will also fail
compensatingAction.setParameterValue(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, QName.createQName("{test}badAspect")); compensatingAction.setParameterValue(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, QName.createQName("{test}badAspect"));
TransactionUtil.executeInUserTransaction( this.transactionService.getRetryingTransactionHelper().doInTransaction(
this.transactionService, new RetryingTransactionCallback<Object>()
new TransactionUtil.TransactionWork<Object>()
{ {
public Object doWork() public Object execute()
{ {
try try
{ {

View File

@@ -29,7 +29,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
@@ -461,10 +461,10 @@ public abstract class AbstractScheduledAction implements ScheduledActionDefiniti
try try
{ {
TransactionUtil.executeInUserTransaction(abstractScheduledAction.getTransactionService(), abstractScheduledAction.getTransactionService().getRetryingTransactionHelper().doInTransaction(
new TransactionUtil.TransactionWork<Object>() new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// Build the full list of compensating actions // Build the full list of compensating actions
// If anything goes wrong we need to do all these instead // If anything goes wrong we need to do all these instead
@@ -561,10 +561,10 @@ public abstract class AbstractScheduledAction implements ScheduledActionDefiniti
try try
{ {
TransactionUtil.executeInUserTransaction(abstractScheduledAction.getTransactionService(), abstractScheduledAction.getTransactionService().getRetryingTransactionHelper().doInTransaction(
new TransactionUtil.TransactionWork<Object>() new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// try action - failure triggers compensation // try action - failure triggers compensation
Action action = abstractScheduledAction.getAction(nodeRef); Action action = abstractScheduledAction.getAction(nodeRef);
@@ -611,10 +611,10 @@ public abstract class AbstractScheduledAction implements ScheduledActionDefiniti
try try
{ {
TransactionUtil.executeInUserTransaction(abstractScheduledAction.getTransactionService(), abstractScheduledAction.getTransactionService().getRetryingTransactionHelper().doInTransaction(
new TransactionUtil.TransactionWork<Object>() new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
try try
{ {

View File

@@ -34,9 +34,7 @@ import org.alfresco.i18n.I18NUtil;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.importer.ImporterBootstrap; import org.alfresco.repo.importer.ImporterBootstrap;
import org.alfresco.repo.node.index.FullIndexRecoveryComponent.RecoveryMode; import org.alfresco.repo.node.index.FullIndexRecoveryComponent.RecoveryMode;
import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionUtil;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.InvalidStoreRefException; import org.alfresco.service.cmr.repository.InvalidStoreRefException;
@@ -173,15 +171,15 @@ public class ConfigurationChecker extends AbstractLifecycleBean
@Override @Override
protected void onBootstrap(ApplicationEvent event) protected void onBootstrap(ApplicationEvent event)
{ {
TransactionWork<Object> checkWork = new TransactionWork<Object>() RetryingTransactionCallback<Object> checkWork = new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
check(); check();
return null; return null;
} }
}; };
TransactionUtil.executeInUserTransaction(transactionService, checkWork); transactionService.getRetryingTransactionHelper().doInTransaction(checkWork);
} }
/** /**
@@ -216,6 +214,7 @@ public class ConfigurationChecker extends AbstractLifecycleBean
// continue; // continue;
//} //}
@SuppressWarnings("unused")
NodeRef rootNodeRef = null; NodeRef rootNodeRef = null;
try try
{ {

View File

@@ -33,8 +33,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.node.integrity.IntegrityChecker; import org.alfresco.repo.node.integrity.IntegrityChecker;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.service.cmr.admin.PatchException; import org.alfresco.service.cmr.admin.PatchException;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.search.SearchService;
@@ -340,9 +339,9 @@ public abstract class AbstractPatch implements Patch
{ {
public String doWork() throws Exception public String doWork() throws Exception
{ {
TransactionWork<String> patchWork = new TransactionWork<String>() RetryingTransactionCallback<String> patchWork = new RetryingTransactionCallback<String>()
{ {
public String doWork() throws Exception public String execute() throws Exception
{ {
// downgrade integrity checking // downgrade integrity checking
@@ -353,8 +352,7 @@ public abstract class AbstractPatch implements Patch
return report; return report;
} }
}; };
return transactionService.getRetryingTransactionHelper().doInTransaction(patchWork);
return TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, patchWork);
} }
}; };
String report = AuthenticationUtil.runAs(authorisedPathWork, AuthenticationUtil.getSystemUserName()); String report = AuthenticationUtil.runAs(authorisedPathWork, AuthenticationUtil.getSystemUserName());

View File

@@ -42,8 +42,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel; import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.domain.PropertyValue; import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.repo.workflow.WorkflowModel; import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.sandbox.SandboxConstants; import org.alfresco.sandbox.SandboxConstants;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor; import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
@@ -170,16 +169,15 @@ public class AVMExpiredContentProcessor
{ {
public String doWork() throws Exception public String doWork() throws Exception
{ {
TransactionWork<String> expiredContentWork = new TransactionWork<String>() RetryingTransactionCallback<String> expiredContentWork = new RetryingTransactionCallback<String>()
{ {
public String doWork() throws Exception public String execute() throws Exception
{ {
processExpiredContent(); processExpiredContent();
return null; return null;
} }
}; };
return transactionService.getRetryingTransactionHelper().doInTransaction(expiredContentWork);
return TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, expiredContentWork);
} }
}; };

View File

@@ -56,7 +56,7 @@ import org.alfresco.repo.search.Indexer;
import org.alfresco.repo.search.impl.lucene.AVMLuceneIndexer; import org.alfresco.repo.search.impl.lucene.AVMLuceneIndexer;
import org.alfresco.repo.search.impl.lucene.LuceneQueryParser; import org.alfresco.repo.search.impl.lucene.LuceneQueryParser;
import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.avm.AVMBadArgumentException; import org.alfresco.service.cmr.avm.AVMBadArgumentException;
import org.alfresco.service.cmr.avm.AVMCycleException; import org.alfresco.service.cmr.avm.AVMCycleException;
import org.alfresco.service.cmr.avm.AVMException; import org.alfresco.service.cmr.avm.AVMException;
@@ -68,11 +68,8 @@ import org.alfresco.service.cmr.avm.LayeringDescriptor;
import org.alfresco.service.cmr.avm.VersionDescriptor; import org.alfresco.service.cmr.avm.VersionDescriptor;
import org.alfresco.service.cmr.avm.deploy.DeploymentReport; import org.alfresco.service.cmr.avm.deploy.DeploymentReport;
import org.alfresco.service.cmr.avm.deploy.DeploymentService; import org.alfresco.service.cmr.avm.deploy.DeploymentService;
import org.alfresco.service.cmr.avm.locking.AVMLockingException;
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
import org.alfresco.service.cmr.avmsync.AVMDifference; import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncException; import org.alfresco.service.cmr.avmsync.AVMSyncException;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.remote.RepoRemote; import org.alfresco.service.cmr.remote.RepoRemote;
import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentData;
@@ -1081,17 +1078,17 @@ public class AVMServiceTest extends AVMServiceTestBase
action.setParameterValue(AVMRevertToVersionAction.TOREVERT, toRevert); action.setParameterValue(AVMRevertToVersionAction.TOREVERT, toRevert);
final AVMRevertToVersionAction revert = (AVMRevertToVersionAction) fContext final AVMRevertToVersionAction revert = (AVMRevertToVersionAction) fContext
.getBean("avm-revert-to-version"); .getBean("avm-revert-to-version");
class TxnWork implements TransactionUtil.TransactionWork<Object> class TxnWork implements RetryingTransactionCallback<Object>
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
revert.execute(action, AVMNodeConverter.ToNodeRef(-1, "main:/a/b/c/foo")); revert.execute(action, AVMNodeConverter.ToNodeRef(-1, "main:/a/b/c/foo"));
return null; return null;
} }
} };
; TransactionService transactionService = (TransactionService) fContext.getBean("transactionService");
TransactionUtil.executeInUserTransaction((TransactionService) fContext.getBean("transactionComponent"), transactionService.getRetryingTransactionHelper().doInTransaction(new TxnWork());
new TxnWork());
results = searchService.query(storeRef, "lucene", "TEXT:\"HEAD\""); results = searchService.query(storeRef, "lucene", "TEXT:\"HEAD\"");
assertEquals(0, results.length()); assertEquals(0, results.length());
results.close(); results.close();
@@ -1774,17 +1771,17 @@ public class AVMServiceTest extends AVMServiceTestBase
action.setParameterValue(AVMRevertListAction.PARAM_VERSION, fService.getLatestSnapshotID("area")); action.setParameterValue(AVMRevertListAction.PARAM_VERSION, fService.getLatestSnapshotID("area"));
action.setParameterValue(AVMRevertListAction.PARAM_NODE_LIST, (Serializable) paths); action.setParameterValue(AVMRevertListAction.PARAM_NODE_LIST, (Serializable) paths);
final AVMRevertListAction revert = (AVMRevertListAction) fContext.getBean("avm-revert-list"); final AVMRevertListAction revert = (AVMRevertListAction) fContext.getBean("avm-revert-list");
class TxnWork implements TransactionUtil.TransactionWork<Object> class TxnWork implements RetryingTransactionCallback<Object>
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
revert.execute(action, null); revert.execute(action, null);
return null; return null;
} }
} };
; TransactionService transactionService = (TransactionService) fContext.getBean("transactionService");
TransactionUtil.executeInUserTransaction((TransactionService) fContext.getBean("transactionComponent"), transactionService.getRetryingTransactionHelper().doInTransaction(new TxnWork());
new TxnWork());
diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null); diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null);
assertEquals(0, diffs.size()); assertEquals(0, diffs.size());
System.out.println(recursiveList("area", -1, true)); System.out.println(recursiveList("area", -1, true));
@@ -1819,17 +1816,17 @@ public class AVMServiceTest extends AVMServiceTestBase
versionPaths.add(new Pair<Integer, String>(-1, "area:/a/b/c/bar")); versionPaths.add(new Pair<Integer, String>(-1, "area:/a/b/c/bar"));
action.setParameterValue(AVMUndoSandboxListAction.PARAM_NODE_LIST, (Serializable) versionPaths); action.setParameterValue(AVMUndoSandboxListAction.PARAM_NODE_LIST, (Serializable) versionPaths);
final AVMUndoSandboxListAction revert = (AVMUndoSandboxListAction) fContext.getBean("avm-undo-list"); final AVMUndoSandboxListAction revert = (AVMUndoSandboxListAction) fContext.getBean("avm-undo-list");
class TxnWork implements TransactionUtil.TransactionWork<Object> class TxnWork implements RetryingTransactionCallback<Object>
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
revert.execute(action, null); revert.execute(action, null);
return null; return null;
} }
} };
; TransactionService transactionService = (TransactionService) fContext.getBean("transactionService");
TransactionUtil.executeInUserTransaction((TransactionService) fContext.getBean("transactionComponent"), transactionService.getRetryingTransactionHelper().doInTransaction(new TxnWork());
new TxnWork());
diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null); diffs = fSyncService.compare(-1, "area:/a", -1, "main:/a", null);
assertEquals(0, diffs.size()); assertEquals(0, diffs.size());
System.out.println(recursiveList("area", -1, true)); System.out.println(recursiveList("area", -1, true));
@@ -1862,18 +1859,18 @@ public class AVMServiceTest extends AVMServiceTestBase
+ JNDIConstants.DIR_DEFAULT_WWW + "/a"), GUID.generate(), SimpleAVMPromoteAction.NAME); + JNDIConstants.DIR_DEFAULT_WWW + "/a"), GUID.generate(), SimpleAVMPromoteAction.NAME);
action.setParameterValue(SimpleAVMPromoteAction.PARAM_TARGET_STORE, "main"); action.setParameterValue(SimpleAVMPromoteAction.PARAM_TARGET_STORE, "main");
final SimpleAVMPromoteAction promote = (SimpleAVMPromoteAction) fContext.getBean("simple-avm-promote"); final SimpleAVMPromoteAction promote = (SimpleAVMPromoteAction) fContext.getBean("simple-avm-promote");
class TxnWork implements TransactionUtil.TransactionWork<Object> class TxnWork implements RetryingTransactionCallback<Object>
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
promote.execute(action, AVMNodeConverter.ToNodeRef(-1, "source:/" promote.execute(action, AVMNodeConverter.ToNodeRef(-1, "source:/"
+ JNDIConstants.DIR_DEFAULT_WWW + "/a")); + JNDIConstants.DIR_DEFAULT_WWW + "/a"));
return null; return null;
} }
} };
; TransactionService transactionService = (TransactionService) fContext.getBean("transactionService");
TransactionUtil.executeInUserTransaction((TransactionService) fContext.getBean("transactionComponent"), transactionService.getRetryingTransactionHelper().doInTransaction(new TxnWork());
new TxnWork());
assertEquals(0, fSyncService.compare(-1, "source:/" + JNDIConstants.DIR_DEFAULT_WWW, -1, assertEquals(0, fSyncService.compare(-1, "source:/" + JNDIConstants.DIR_DEFAULT_WWW, -1,
"main:/" + JNDIConstants.DIR_DEFAULT_WWW, null).size()); "main:/" + JNDIConstants.DIR_DEFAULT_WWW, null).size());
} }
@@ -1935,18 +1932,17 @@ public class AVMServiceTest extends AVMServiceTestBase
"foo-staging:/" + JNDIConstants.DIR_DEFAULT_WWW, null); "foo-staging:/" + JNDIConstants.DIR_DEFAULT_WWW, null);
assertEquals(3, diffs.size()); assertEquals(3, diffs.size());
final SimpleAVMSubmitAction action = (SimpleAVMSubmitAction) fContext.getBean("simple-avm-submit"); final SimpleAVMSubmitAction action = (SimpleAVMSubmitAction) fContext.getBean("simple-avm-submit");
class TxnWork implements TransactionUtil.TransactionWork<Object> class TxnWork implements RetryingTransactionCallback<Object>
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
action.execute(null, AVMNodeConverter.ToNodeRef(-1, "area:/" + JNDIConstants.DIR_DEFAULT_WWW)); action.execute(null, AVMNodeConverter.ToNodeRef(-1, "area:/" + JNDIConstants.DIR_DEFAULT_WWW));
return null; return null;
} }
} };
; TransactionService transactionService = (TransactionService) fContext.getBean("transactionService");
TxnWork worker = new TxnWork(); transactionService.getRetryingTransactionHelper().doInTransaction(new TxnWork());
TransactionUtil.executeInUserTransaction((TransactionService) fContext.getBean("transactionComponent"),
worker);
diffs = fSyncService.compare(-1, "area:/" + JNDIConstants.DIR_DEFAULT_WWW, -1, "foo-staging:/" diffs = fSyncService.compare(-1, "area:/" + JNDIConstants.DIR_DEFAULT_WWW, -1, "foo-staging:/"
+ JNDIConstants.DIR_DEFAULT_WWW, null); + JNDIConstants.DIR_DEFAULT_WWW, null);
@@ -5355,7 +5351,7 @@ public class AVMServiceTest extends AVMServiceTestBase
try try
{ {
setupBasicTree(); setupBasicTree();
class TxnCallback implements RetryingTransactionHelper.RetryingTransactionCallback class TxnCallback implements RetryingTransactionHelper.RetryingTransactionCallback<Object>
{ {
public Object execute() public Object execute()
{ {
@@ -5412,8 +5408,8 @@ public class AVMServiceTest extends AVMServiceTestBase
} }
} }
} }
RetryingTransactionHelper helper = (RetryingTransactionHelper) fContext TransactionService transactionService = (TransactionService) fContext.getBean("transactionService");
.getBean("retryingTransactionHelper"); RetryingTransactionHelper helper = transactionService.getRetryingTransactionHelper();
helper.doInTransaction(new TxnCallback(), false); helper.doInTransaction(new TxnCallback(), false);
assertNotNull(fService.lookup(-1, "main:/layer/b/c/groo")); assertNotNull(fService.lookup(-1, "main:/layer/b/c/groo"));
} }

View File

@@ -23,7 +23,7 @@
package org.alfresco.repo.avm; package org.alfresco.repo.avm;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
/** /**
@@ -73,16 +73,14 @@ public class Issuer
*/ */
public void initialize() public void initialize()
{ {
class TxnWork implements TransactionUtil.TransactionWork<Long> class TxnWork implements RetryingTransactionCallback<Long>
{ {
public Long doWork() throws Exception public Long execute() throws Exception
{ {
return AVMDAOs.Instance().fIssuerDAO.getIssuerValue(fName); return AVMDAOs.Instance().fIssuerDAO.getIssuerValue(fName);
} }
} }
Long result = TransactionUtil.executeInUserTransaction(fTransactionService, Long result = fTransactionService.getRetryingTransactionHelper().doInTransaction(new TxnWork(), true);
new TxnWork(),
true);
if (result == null) if (result == null)
{ {
fNext = 0L; fNext = 0L;

View File

@@ -27,7 +27,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.alfresco.repo.domain.DbAccessControlList; import org.alfresco.repo.domain.DbAccessControlList;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
@@ -242,9 +242,9 @@ public class OrphanReaper
*/ */
public void doBatch() public void doBatch()
{ {
class TxnWork implements TransactionUtil.TransactionWork<Object> class TxnWork implements RetryingTransactionCallback<Object>
{ {
public Object doWork() public Object execute()
throws Exception throws Exception
{ {
if (fPurgeQueue == null) if (fPurgeQueue == null)
@@ -341,8 +341,7 @@ public class OrphanReaper
} }
try try
{ {
TransactionUtil.executeInUserTransaction(fTransactionService, fTransactionService.getRetryingTransactionHelper().doInTransaction(new TxnWork());
new TxnWork());
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -26,17 +26,15 @@ package org.alfresco.repo.coci;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.version.VersionModel; import org.alfresco.repo.version.VersionModel;
import org.alfresco.service.cmr.coci.CheckOutCheckInService; import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.service.cmr.lock.LockService; import org.alfresco.service.cmr.lock.LockService;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentReader;
@@ -419,11 +417,10 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest
final NodeRef finalNodeRef = origNodeRef; final NodeRef finalNodeRef = origNodeRef;
TransactionUtil.executeInUserTransaction( this.transactionService.getRetryingTransactionHelper().doInTransaction(
this.transactionService, new RetryingTransactionCallback<Object>()
new TransactionUtil.TransactionWork<Object>()
{ {
public Object doWork() public Object execute()
{ {
NodeRef wk2 = CheckOutCheckInServiceImplTest.this.cociService.getWorkingCopy(finalNodeRef); NodeRef wk2 = CheckOutCheckInServiceImplTest.this.cociService.getWorkingCopy(finalNodeRef);
assertNotNull(wk2); assertNotNull(wk2);
@@ -432,7 +429,6 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest
CheckOutCheckInServiceImplTest.this.cociService.cancelCheckout(workingCopy); CheckOutCheckInServiceImplTest.this.cociService.cancelCheckout(workingCopy);
return null; return null;
} }
}); });
NodeRef wk3 = this.cociService.getWorkingCopy(this.nodeRef); NodeRef wk3 = this.cociService.getWorkingCopy(this.nodeRef);

View File

@@ -35,8 +35,7 @@ import java.util.Properties;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.importer.ImporterBootstrap; import org.alfresco.repo.importer.ImporterBootstrap;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
@@ -163,9 +162,9 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
{ {
// initialise the repository descriptor // initialise the repository descriptor
// note: this requires that the repository schema has already been initialised // note: this requires that the repository schema has already been initialised
TransactionWork<Descriptor> createDescriptorWork = new TransactionUtil.TransactionWork<Descriptor>() RetryingTransactionCallback<Descriptor> createDescriptorWork = new RetryingTransactionCallback<Descriptor>()
{ {
public Descriptor doWork() public Descriptor execute()
{ {
// initialise license service (if installed) // initialise license service (if installed)
initialiseLicenseService(); initialiseLicenseService();
@@ -180,7 +179,7 @@ public class DescriptorServiceImpl extends AbstractLifecycleBean implements Desc
return createInstalledRepositoryDescriptor(); return createInstalledRepositoryDescriptor();
} }
}; };
installedRepoDescriptor = TransactionUtil.executeInUserTransaction(transactionService, createDescriptorWork); installedRepoDescriptor = transactionService.getRetryingTransactionHelper().doInTransaction(createDescriptorWork);
} }
@Override @Override

View File

@@ -26,7 +26,7 @@ package org.alfresco.repo.dictionary;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.coci.CheckOutCheckInService; import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.service.cmr.dictionary.DictionaryException; import org.alfresco.service.cmr.dictionary.DictionaryException;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
@@ -180,9 +180,9 @@ public class DictionaryModelTypeTest extends BaseAlfrescoSpringTest
setComplete(); setComplete();
endTransaction(); endTransaction();
final NodeRef workingCopy = TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<NodeRef>() final NodeRef workingCopy = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<NodeRef>()
{ {
public NodeRef doWork() throws Exception public NodeRef execute() throws Exception
{ {
// Check that the meta data has been extracted from the model // Check that the meta data has been extracted from the model
assertEquals(QName.createQName("{http://www.alfresco.org/test/testmodel1/1.0}testModelOne"), assertEquals(QName.createQName("{http://www.alfresco.org/test/testmodel1/1.0}testModelOne"),
@@ -210,9 +210,9 @@ public class DictionaryModelTypeTest extends BaseAlfrescoSpringTest
} }
}); });
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// Check that the policy has not been fired since we have updated a working copy // Check that the policy has not been fired since we have updated a working copy
assertEquals("1.0", DictionaryModelTypeTest.this.nodeService.getProperty(workingCopy, ContentModel.PROP_MODEL_VERSION)); assertEquals("1.0", DictionaryModelTypeTest.this.nodeService.getProperty(workingCopy, ContentModel.PROP_MODEL_VERSION));
@@ -223,9 +223,9 @@ public class DictionaryModelTypeTest extends BaseAlfrescoSpringTest
} }
}); });
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// Now check that the model has been updated // Now check that the model has been updated
assertEquals("1.1", DictionaryModelTypeTest.this.nodeService.getProperty(modelNode, ContentModel.PROP_MODEL_VERSION)); assertEquals("1.1", DictionaryModelTypeTest.this.nodeService.getProperty(modelNode, ContentModel.PROP_MODEL_VERSION));
@@ -270,9 +270,9 @@ public class DictionaryModelTypeTest extends BaseAlfrescoSpringTest
setComplete(); setComplete();
endTransaction(); endTransaction();
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// The model should not yet be loaded // The model should not yet be loaded
try try
@@ -293,9 +293,9 @@ public class DictionaryModelTypeTest extends BaseAlfrescoSpringTest
} }
}); });
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// The model should now be loaded // The model should now be loaded
assertNotNull(DictionaryModelTypeTest.this.dictionaryService.getModel(TEST_MODEL_ONE)); assertNotNull(DictionaryModelTypeTest.this.dictionaryService.getModel(TEST_MODEL_ONE));
@@ -307,9 +307,9 @@ public class DictionaryModelTypeTest extends BaseAlfrescoSpringTest
} }
}); });
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// The model should not be loaded // The model should not be loaded
try try
@@ -330,9 +330,9 @@ public class DictionaryModelTypeTest extends BaseAlfrescoSpringTest
} }
}); });
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// The model should now be loaded // The model should now be loaded
assertNotNull(DictionaryModelTypeTest.this.dictionaryService.getModel(TEST_MODEL_ONE)); assertNotNull(DictionaryModelTypeTest.this.dictionaryService.getModel(TEST_MODEL_ONE));

View File

@@ -31,7 +31,7 @@ import java.util.Map;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
@@ -131,9 +131,9 @@ public class DictionaryRepositoryBootstrap
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void bootstrap() public void bootstrap()
{ {
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
DictionaryRepositoryBootstrap.this.authenticationComponent.setCurrentUser( DictionaryRepositoryBootstrap.this.authenticationComponent.setCurrentUser(
DictionaryRepositoryBootstrap.this.authenticationComponent.getSystemUserName()); DictionaryRepositoryBootstrap.this.authenticationComponent.getSystemUserName());

View File

@@ -35,8 +35,8 @@ import java.util.Map;
import org.alfresco.model.ApplicationModel; import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentData;
@@ -170,25 +170,26 @@ public class FileImporterImpl implements FileImporter
boolean recurse, boolean recurse,
final String containerName) throws Throwable final String containerName) throws Throwable
{ {
RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
if (containerName != null) if (containerName != null)
{ {
TransactionWork<NodeRef> createDirectoryWork = new TransactionWork<NodeRef>() RetryingTransactionCallback<NodeRef> createDirectoryWork = new RetryingTransactionCallback<NodeRef>()
{ {
public NodeRef doWork() throws Exception public NodeRef execute() throws Exception
{ {
return createDirectory(container, containerName, containerName); return createDirectory(container, containerName, containerName);
} }
}; };
NodeRef newContainer = TransactionUtil.executeInUserTransaction(transactionService, createDirectoryWork); NodeRef newContainer = txnHelper.doInTransaction(createDirectoryWork);
return create(counter, newContainer, file, filter, recurse, null); return create(counter, newContainer, file, filter, recurse, null);
} }
if (file.isDirectory()) if (file.isDirectory())
{ {
counter.increment(); counter.increment();
TransactionWork<NodeRef> createDirectoryWork = new TransactionWork<NodeRef>() RetryingTransactionCallback<NodeRef> createDirectoryWork = new RetryingTransactionCallback<NodeRef>()
{ {
public NodeRef doWork() throws Exception public NodeRef execute() throws Exception
{ {
return createDirectory(container, file); return createDirectory(container, file);
} }
@@ -196,13 +197,11 @@ public class FileImporterImpl implements FileImporter
NodeRef directoryNodeRef = null; NodeRef directoryNodeRef = null;
if (txnPerFile) if (txnPerFile)
{ {
directoryNodeRef = TransactionUtil.executeInUserTransaction( directoryNodeRef = txnHelper.doInTransaction(createDirectoryWork);
transactionService,
createDirectoryWork);
} }
else else
{ {
directoryNodeRef = createDirectoryWork.doWork(); directoryNodeRef = createDirectoryWork.execute();
} }
if (recurse) if (recurse)
@@ -219,9 +218,9 @@ public class FileImporterImpl implements FileImporter
else else
{ {
counter.increment(); counter.increment();
TransactionWork<NodeRef> createFileWork = new TransactionWork<NodeRef>() RetryingTransactionCallback<NodeRef> createFileWork = new RetryingTransactionCallback<NodeRef>()
{ {
public NodeRef doWork() throws Exception public NodeRef execute() throws Exception
{ {
return createFile(container, file); return createFile(container, file);
} }
@@ -229,13 +228,11 @@ public class FileImporterImpl implements FileImporter
NodeRef fileNodeRef = null; NodeRef fileNodeRef = null;
if (txnPerFile) if (txnPerFile)
{ {
fileNodeRef = TransactionUtil.executeInUserTransaction( fileNodeRef = txnHelper.doInTransaction(createFileWork);
transactionService,
createFileWork);
} }
else else
{ {
fileNodeRef = createFileWork.doWork(); fileNodeRef = createFileWork.execute();
} }
return fileNodeRef; return fileNodeRef;
} }

View File

@@ -37,7 +37,7 @@ import org.alfresco.repo.dictionary.DictionaryDAO;
import org.alfresco.repo.dictionary.M2Model; import org.alfresco.repo.dictionary.M2Model;
import org.alfresco.repo.node.BaseNodeServiceTest; import org.alfresco.repo.node.BaseNodeServiceTest;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentService;
@@ -113,11 +113,10 @@ public class RhinoScriptTest extends TestCase
public void testRhinoIntegration() public void testRhinoIntegration()
{ {
TransactionUtil.executeInUserTransaction( transactionService.getRetryingTransactionHelper().doInTransaction(
transactionService, new RetryingTransactionCallback<Object>()
new TransactionUtil.TransactionWork<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// check that rhino script engine is available // check that rhino script engine is available
Context cx = Context.enter(); Context cx = Context.enter();
@@ -161,11 +160,10 @@ public class RhinoScriptTest extends TestCase
public void testJSObjectWrapping() public void testJSObjectWrapping()
{ {
TransactionUtil.executeInUserTransaction( transactionService.getRetryingTransactionHelper().doInTransaction(
transactionService, new RetryingTransactionCallback<Object>()
new TransactionUtil.TransactionWork<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
StoreRef store = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "rhino_" + System.currentTimeMillis()); StoreRef store = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "rhino_" + System.currentTimeMillis());
NodeRef root = nodeService.getRootNode(store); NodeRef root = nodeService.getRootNode(store);
@@ -215,11 +213,10 @@ public class RhinoScriptTest extends TestCase
public void testScriptService() public void testScriptService()
{ {
TransactionUtil.executeInUserTransaction( transactionService.getRetryingTransactionHelper().doInTransaction(
transactionService, new RetryingTransactionCallback<Object>()
new TransactionUtil.TransactionWork<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
StoreRef store = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "rhino_" + System.currentTimeMillis()); StoreRef store = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "rhino_" + System.currentTimeMillis());
NodeRef root = nodeService.getRootNode(store); NodeRef root = nodeService.getRootNode(store);
@@ -274,11 +271,10 @@ public class RhinoScriptTest extends TestCase
public void testScriptActions() public void testScriptActions()
{ {
TransactionUtil.executeInUserTransaction( transactionService.getRetryingTransactionHelper().doInTransaction(
transactionService, new RetryingTransactionCallback<Object>()
new TransactionUtil.TransactionWork<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
StoreRef store = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "rhino_" + System.currentTimeMillis()); StoreRef store = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "rhino_" + System.currentTimeMillis());
NodeRef root = nodeService.getRootNode(store); NodeRef root = nodeService.getRootNode(store);
@@ -329,11 +325,10 @@ public class RhinoScriptTest extends TestCase
public void xtestScriptActionsMail() public void xtestScriptActionsMail()
{ {
TransactionUtil.executeInUserTransaction( transactionService.getRetryingTransactionHelper().doInTransaction(
transactionService, new RetryingTransactionCallback<Object>()
new TransactionUtil.TransactionWork<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
StoreRef store = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "rhino_" + System.currentTimeMillis()); StoreRef store = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "rhino_" + System.currentTimeMillis());
NodeRef root = nodeService.getRootNode(store); NodeRef root = nodeService.getRootNode(store);

View File

@@ -40,8 +40,7 @@ import org.alfresco.i18n.I18NUtil;
import org.alfresco.repo.admin.registry.RegistryKey; import org.alfresco.repo.admin.registry.RegistryKey;
import org.alfresco.repo.admin.registry.RegistryService; import org.alfresco.repo.admin.registry.RegistryService;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.module.ModuleDependency; import org.alfresco.service.cmr.module.ModuleDependency;
import org.alfresco.service.cmr.module.ModuleDetails; import org.alfresco.service.cmr.module.ModuleDetails;
@@ -215,15 +214,15 @@ public class ModuleComponentHelper
final Set<String> startedModules = new HashSet<String>(2); final Set<String> startedModules = new HashSet<String>(2);
for (final ModuleDetails module : modules) for (final ModuleDetails module : modules)
{ {
TransactionWork<Object> startModuleWork = new TransactionWork<Object>() RetryingTransactionCallback<Object> startModuleWork = new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
startModule(module, startedModules, executedComponents); startModule(module, startedModules, executedComponents);
return null; return null;
} }
}; };
TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, startModuleWork); transactionService.getRetryingTransactionHelper().doInTransaction(startModuleWork);
} }
// Check for missing modules. // Check for missing modules.

View File

@@ -37,8 +37,7 @@ import org.alfresco.repo.dictionary.DictionaryDAO;
import org.alfresco.repo.dictionary.M2Model; import org.alfresco.repo.dictionary.M2Model;
import org.alfresco.repo.node.integrity.IntegrityChecker; import org.alfresco.repo.node.integrity.IntegrityChecker;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentService;
@@ -109,9 +108,9 @@ public class PerformanceNodeServiceTest extends TestCase
contentService = (ContentService) applicationContext.getBean("contentService"); contentService = (ContentService) applicationContext.getBean("contentService");
// create a first store directly // create a first store directly
TransactionWork<NodeRef> createStoreWork = new TransactionWork<NodeRef>() RetryingTransactionCallback<NodeRef> createStoreWork = new RetryingTransactionCallback<NodeRef>()
{ {
public NodeRef doWork() public NodeRef execute()
{ {
StoreRef storeRef = nodeService.createStore( StoreRef storeRef = nodeService.createStore(
StoreRef.PROTOCOL_WORKSPACE, StoreRef.PROTOCOL_WORKSPACE,
@@ -119,7 +118,7 @@ public class PerformanceNodeServiceTest extends TestCase
return nodeService.getRootNode(storeRef); return nodeService.getRootNode(storeRef);
} }
}; };
rootNodeRef = TransactionUtil.executeInUserTransaction(txnService, createStoreWork); rootNodeRef = txnService.getRetryingTransactionHelper().doInTransaction(createStoreWork);
} }
@Override @Override
@@ -165,16 +164,16 @@ public class PerformanceNodeServiceTest extends TestCase
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
// ensure that we execute the node tree building in a transaction // ensure that we execute the node tree building in a transaction
TransactionWork<Object> buildChildrenWork = new TransactionWork<Object>() RetryingTransactionCallback<Object> buildChildrenWork = new RetryingTransactionCallback<Object>()
{ {
public Object doWork() public Object execute()
{ {
IntegrityChecker.setWarnInTransaction(); IntegrityChecker.setWarnInTransaction();
buildNodeChildren(rootNodeRef, 1, testDepth, testChildCount); buildNodeChildren(rootNodeRef, 1, testDepth, testChildCount);
return null; return null;
} }
}; };
TransactionUtil.executeInUserTransaction(txnService, buildChildrenWork); txnService.getRetryingTransactionHelper().doInTransaction(buildChildrenWork);
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();

View File

@@ -4,8 +4,7 @@ import java.util.List;
import org.alfresco.repo.node.index.FullIndexRecoveryComponent.RecoveryMode; import org.alfresco.repo.node.index.FullIndexRecoveryComponent.RecoveryMode;
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor; import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor; import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@@ -199,9 +198,9 @@ public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
logger.debug("Reindexing avm store: " + store + " snapshot id " + id); logger.debug("Reindexing avm store: " + store + " snapshot id " + id);
} }
TransactionWork<Object> reindexWork = new TransactionWork<Object>() RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
if (!avmSnapShotTriggeredIndexingMethodInterceptor.isSnapshotIndexed(store, id)) if (!avmSnapShotTriggeredIndexingMethodInterceptor.isSnapshotIndexed(store, id))
{ {
@@ -211,7 +210,7 @@ public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
return null; return null;
} }
}; };
TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, reindexWork, true); transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true);
// done // done
} }

View File

@@ -39,8 +39,7 @@ import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.TransactionServiceImpl; import org.alfresco.repo.transaction.TransactionServiceImpl;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
@@ -210,15 +209,15 @@ public abstract class AbstractReindexComponent implements IndexRecovery
auth = AuthenticationUtil.getCurrentAuthentication(); auth = AuthenticationUtil.getCurrentAuthentication();
// authenticate as the system user // authenticate as the system user
authenticationComponent.setSystemUserAsCurrentUser(); authenticationComponent.setSystemUserAsCurrentUser();
TransactionWork<Object> reindexWork = new TransactionWork<Object>() RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
reindexImpl(); reindexImpl();
return null; return null;
} }
}; };
TransactionUtil.executeInUserTransaction(transactionService, reindexWork); transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork);
} }
finally finally
{ {
@@ -426,9 +425,9 @@ public abstract class AbstractReindexComponent implements IndexRecovery
logger.debug("Reindexing transaction: " + txnId); logger.debug("Reindexing transaction: " + txnId);
} }
TransactionWork<Object> reindexWork = new TransactionWork<Object>() RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// get the node references pertinent to the transaction // get the node references pertinent to the transaction
List<NodeRef> nodeRefs = nodeDaoService.getTxnChanges(txnId); List<NodeRef> nodeRefs = nodeDaoService.getTxnChanges(txnId);
@@ -461,7 +460,7 @@ public abstract class AbstractReindexComponent implements IndexRecovery
return null; return null;
} }
}; };
TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, reindexWork, true); transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true);
// done // done
} }
} }

View File

@@ -29,8 +29,7 @@ import java.util.List;
import org.alfresco.i18n.I18NUtil; import org.alfresco.i18n.I18NUtil;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.domain.Transaction; import org.alfresco.repo.domain.Transaction;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeRef.Status; import org.alfresco.service.cmr.repository.NodeRef.Status;
@@ -243,9 +242,9 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent
logger.debug("Reindexing transaction: " + txnId); logger.debug("Reindexing transaction: " + txnId);
} }
TransactionWork<Object> reindexWork = new TransactionWork<Object>() RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// get the node references pertinent to the transaction // get the node references pertinent to the transaction
List<NodeRef> nodeRefs = nodeDaoService.getTxnChanges(txnId); List<NodeRef> nodeRefs = nodeDaoService.getTxnChanges(txnId);
@@ -278,7 +277,7 @@ public class FullIndexRecoveryComponent extends AbstractReindexComponent
return null; return null;
} }
}; };
TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, reindexWork, true); transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true);
// done // done
} }
} }

View File

@@ -33,8 +33,7 @@ import org.alfresco.repo.search.Indexer;
import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer; import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.TransactionServiceImpl; import org.alfresco.repo.transaction.TransactionServiceImpl;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -95,9 +94,9 @@ public class IndexRemoteTransactionTrackerTest extends TestCase
authenticationComponent.setSystemUserAsCurrentUser(); authenticationComponent.setSystemUserAsCurrentUser();
// disable indexing // disable indexing
TransactionWork<ChildAssociationRef> createNodeWork = new TransactionWork<ChildAssociationRef>() RetryingTransactionCallback<ChildAssociationRef> createNodeWork = new RetryingTransactionCallback<ChildAssociationRef>()
{ {
public ChildAssociationRef doWork() throws Exception public ChildAssociationRef execute() throws Exception
{ {
StoreRef storeRef = new StoreRef("test", getName() + "-" + System.currentTimeMillis()); StoreRef storeRef = new StoreRef("test", getName() + "-" + System.currentTimeMillis());
NodeRef rootNodeRef = null; NodeRef rootNodeRef = null;
@@ -117,7 +116,7 @@ public class IndexRemoteTransactionTrackerTest extends TestCase
return childAssocRef; return childAssocRef;
} }
}; };
ChildAssociationRef childAssocRef = TransactionUtil.executeInUserTransaction(transactionService, createNodeWork); ChildAssociationRef childAssocRef = transactionService.getRetryingTransactionHelper().doInTransaction(createNodeWork);
} }
public void testSetup() throws Exception public void testSetup() throws Exception

View File

@@ -27,8 +27,7 @@ package org.alfresco.repo.node.index;
import java.util.List; import java.util.List;
import org.alfresco.repo.search.impl.lucene.AbstractLuceneIndexerImpl; import org.alfresco.repo.search.impl.lucene.AbstractLuceneIndexerImpl;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.ResultSet; import org.alfresco.service.cmr.search.ResultSet;
@@ -113,15 +112,15 @@ public class MissingContentReindexComponent extends AbstractReindexComponent
{ {
final NodeRef childNodeRef = row.getNodeRef(); final NodeRef childNodeRef = row.getNodeRef();
// prompt for a reindex - it might fail again, but we just keep plugging away // prompt for a reindex - it might fail again, but we just keep plugging away
TransactionWork<Object> reindexWork = new TransactionWork<Object>() RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
{ {
public Object doWork() public Object execute()
{ {
indexer.updateNode(childNodeRef); indexer.updateNode(childNodeRef);
return null; return null;
} }
}; };
TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, reindexWork); transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork);
// check if we have to break out // check if we have to break out
if (isShuttingDown()) if (isShuttingDown())
{ {

View File

@@ -46,8 +46,7 @@ import org.alfresco.repo.search.impl.lucene.index.IndexInfo;
import org.alfresco.repo.search.transaction.SimpleTransaction; import org.alfresco.repo.search.transaction.SimpleTransaction;
import org.alfresco.repo.search.transaction.SimpleTransactionManager; import org.alfresco.repo.search.transaction.SimpleTransactionManager;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
@@ -965,15 +964,15 @@ public abstract class AbstractLuceneIndexerAndSearcherFactory implements LuceneI
*/ */
public void backup() public void backup()
{ {
TransactionWork<Object> backupWork = new TransactionWork<Object>() RetryingTransactionCallback<Object> backupWork = new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
backupImpl(); backupImpl();
return null; return null;
} }
}; };
TransactionUtil.executeInUserTransaction(transactionService, backupWork); transactionService.getRetryingTransactionHelper().doInTransaction(backupWork);
} }
private void backupImpl() private void backupImpl()

View File

@@ -19,7 +19,7 @@ package org.alfresco.repo.security.person;
import java.util.Set; import java.util.Set;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
@@ -78,11 +78,10 @@ public class SplitPersonCleanupBootstrapBean extends AbstractLifecycleBean
*/ */
private int removePeopleWithGUIDBasedIds() private int removePeopleWithGUIDBasedIds()
{ {
Integer count = TransactionUtil.executeInUserTransaction(transactionService, Integer count = transactionService.getRetryingTransactionHelper().doInTransaction(
new TransactionUtil.TransactionWork<Integer>() new RetryingTransactionCallback<Integer>()
{ {
public Integer execute() throws Exception
public Integer doWork() throws Exception
{ {
int count = 0; int count = 0;
// A GUID should be 36 chars // A GUID should be 36 chars
@@ -121,6 +120,7 @@ public class SplitPersonCleanupBootstrapBean extends AbstractLifecycleBean
String guidString = uid.substring(uid.length() - 36); String guidString = uid.substring(uid.length() - 36);
try try
{ {
@SuppressWarnings("unused")
UUID id = new UUID(guidString); UUID id = new UUID(guidString);
// We have a valid guid. // We have a valid guid.
return true; return true;
@@ -140,6 +140,7 @@ public class SplitPersonCleanupBootstrapBean extends AbstractLifecycleBean
guidString = guidString.substring(1, 37); guidString = guidString.substring(1, 37);
try try
{ {
@SuppressWarnings("unused")
UUID id = new UUID(guidString); UUID id = new UUID(guidString);
// We have a valid guid. // We have a valid guid.
return true; return true;

View File

@@ -34,11 +34,9 @@ import org.alfresco.repo.dictionary.DictionaryComponent;
import org.alfresco.repo.dictionary.DictionaryDAO; import org.alfresco.repo.dictionary.DictionaryDAO;
import org.alfresco.repo.dictionary.M2Model; import org.alfresco.repo.dictionary.M2Model;
import org.alfresco.repo.node.BaseNodeServiceTest; import org.alfresco.repo.node.BaseNodeServiceTest;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
@@ -54,7 +52,6 @@ public class TemplateServiceImplTest extends TestCase
{ {
private static final ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); private static final ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
private ContentService contentService;
private TemplateService templateService; private TemplateService templateService;
private NodeService nodeService; private NodeService nodeService;
private TransactionService transactionService; private TransactionService transactionService;
@@ -68,11 +65,10 @@ public class TemplateServiceImplTest extends TestCase
{ {
super.setUp(); super.setUp();
transactionService = (TransactionService)this.ctx.getBean("transactionComponent"); transactionService = (TransactionService)ctx.getBean("transactionComponent");
contentService = (ContentService)this.ctx.getBean("contentService"); nodeService = (NodeService)ctx.getBean("nodeService");
nodeService = (NodeService)this.ctx.getBean("nodeService"); templateService = (TemplateService)ctx.getBean("templateService");
templateService = (TemplateService)this.ctx.getBean("templateService"); serviceRegistry = (ServiceRegistry)ctx.getBean("ServiceRegistry");
serviceRegistry = (ServiceRegistry)this.ctx.getBean("ServiceRegistry");
this.authenticationComponent = (AuthenticationComponent)ctx.getBean("authenticationComponent"); this.authenticationComponent = (AuthenticationComponent)ctx.getBean("authenticationComponent");
this.authenticationComponent.setSystemUserAsCurrentUser(); this.authenticationComponent.setSystemUserAsCurrentUser();
@@ -106,12 +102,11 @@ public class TemplateServiceImplTest extends TestCase
public void testTemplates() public void testTemplates()
{ {
TransactionUtil.executeInUserTransaction( transactionService.getRetryingTransactionHelper().doInTransaction(
transactionService, new RetryingTransactionCallback<Object>()
new TransactionUtil.TransactionWork<Object>()
{ {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Object doWork() throws Exception public Object execute() throws Exception
{ {
StoreRef store = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "template_" + System.currentTimeMillis()); StoreRef store = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "template_" + System.currentTimeMillis());
NodeRef root = nodeService.getRootNode(store); NodeRef root = nodeService.getRootNode(store);

View File

@@ -31,7 +31,7 @@ import javax.transaction.UserTransaction;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ApplicationContextHelper;
@@ -224,9 +224,9 @@ public class AlfrescoTransactionSupportTest extends TestCase
} }
}; };
// start a transaction // start a transaction
TransactionWork<Object> bindWork = new TransactionWork<Object>() RetryingTransactionCallback<Object> bindWork = new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// just bind the listener to the transaction // just bind the listener to the transaction
AlfrescoTransactionSupport.bindListener(dummyListener); AlfrescoTransactionSupport.bindListener(dummyListener);
@@ -235,7 +235,7 @@ public class AlfrescoTransactionSupportTest extends TestCase
} }
}; };
// kick it all off // kick it all off
TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, bindWork); transactionService.getRetryingTransactionHelper().doInTransaction(bindWork);
// make sure that the binding all worked // make sure that the binding all worked
assertTrue("Expected callbacks not all processed: " + testList, testList.size() == 0); assertTrue("Expected callbacks not all processed: " + testList, testList.size() == 0);

View File

@@ -30,7 +30,7 @@ import javax.transaction.UserTransaction;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ApplicationContextHelper;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
@@ -212,22 +212,15 @@ public class TransactionAwareSingletonTest extends TestCase
private void check(final Integer expected, boolean inTransaction) private void check(final Integer expected, boolean inTransaction)
{ {
TransactionWork<Object> checkWork = new TransactionWork<Object>() RetryingTransactionCallback<Object> checkWork = new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
Integer actual = singleton.get(); Integer actual = singleton.get();
assertTrue("Values don't match: " + expected + " != " + actual, actual == expected); assertTrue("Values don't match: " + expected + " != " + actual, actual == expected);
return null; return null;
} }
}; };
if (inTransaction) transactionService.getRetryingTransactionHelper().doInTransaction(checkWork, false, !inTransaction);
{
TransactionUtil.executeInUserTransaction(transactionService, checkWork);
}
else
{
TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, checkWork);
}
} }
} }

View File

@@ -34,7 +34,6 @@ import java.util.Set;
import org.alfresco.model.ApplicationModel; import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.TransactionUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.model.FileFolderService;
@@ -472,9 +471,9 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
setComplete(); setComplete();
endTransaction(); endTransaction();
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// Check that the initial version has not been created // Check that the initial version has not been created
VersionHistory versionHistory = VersionServiceImplTest.this.versionService.getVersionHistory(versionableNode); VersionHistory versionHistory = VersionServiceImplTest.this.versionService.getVersionHistory(versionableNode);
@@ -491,9 +490,9 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
}); });
// Now lets have a look and make sure we have the correct number of entries in the version history // Now lets have a look and make sure we have the correct number of entries in the version history
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
VersionHistory versionHistory = VersionServiceImplTest.this.versionService.getVersionHistory(versionableNode); VersionHistory versionHistory = VersionServiceImplTest.this.versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory); assertNotNull(versionHistory);
@@ -516,9 +515,9 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
// The initial version should have been created now // The initial version should have been created now
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// Add some content // Add some content
ContentWriter contentWriter = VersionServiceImplTest.this.contentService.getWriter(versionableNode, ContentModel.PROP_CONTENT, true); ContentWriter contentWriter = VersionServiceImplTest.this.contentService.getWriter(versionableNode, ContentModel.PROP_CONTENT, true);
@@ -530,9 +529,9 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
}); });
// Now lets have a look and make sure we have the correct number of entries in the version history // Now lets have a look and make sure we have the correct number of entries in the version history
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
VersionHistory versionHistory = VersionServiceImplTest.this.versionService.getVersionHistory(versionableNode); VersionHistory versionHistory = VersionServiceImplTest.this.versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory); assertNotNull(versionHistory);
@@ -564,9 +563,9 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
// The initial version should NOT have been created // The initial version should NOT have been created
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
VersionHistory versionHistory = VersionServiceImplTest.this.versionService.getVersionHistory(nodeRef); VersionHistory versionHistory = VersionServiceImplTest.this.versionService.getVersionHistory(nodeRef);
assertNull(versionHistory); assertNull(versionHistory);
@@ -592,9 +591,9 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
setComplete(); setComplete();
endTransaction(); endTransaction();
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// Check that the version history has been created // Check that the version history has been created
VersionHistory versionHistory = VersionServiceImplTest.this.versionService.getVersionHistory(nodeRef); VersionHistory versionHistory = VersionServiceImplTest.this.versionService.getVersionHistory(nodeRef);
@@ -608,9 +607,9 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
} }
}); });
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// Check that the version history has been removed // Check that the version history has been removed
VersionHistory versionHistory = VersionServiceImplTest.this.versionService.getVersionHistory(nodeRef); VersionHistory versionHistory = VersionServiceImplTest.this.versionService.getVersionHistory(nodeRef);
@@ -623,9 +622,9 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
} }
}); });
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// Check that the version history has been created // Check that the version history has been created
VersionHistory versionHistory = VersionServiceImplTest.this.versionService.getVersionHistory(nodeRef); VersionHistory versionHistory = VersionServiceImplTest.this.versionService.getVersionHistory(nodeRef);
@@ -655,9 +654,9 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
setComplete(); setComplete();
endTransaction(); endTransaction();
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
VersionHistory versionHistory = VersionServiceImplTest.this.versionService.getVersionHistory(nodeRef); VersionHistory versionHistory = VersionServiceImplTest.this.versionService.getVersionHistory(nodeRef);
assertNotNull(versionHistory); assertNotNull(versionHistory);
@@ -670,9 +669,9 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
} }
}); });
TransactionUtil.executeInUserTransaction(this.transactionService, new TransactionUtil.TransactionWork<Object>() transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// Get the archived noderef // Get the archived noderef
NodeRef archivedNodeRef = VersionServiceImplTest.this.nodeArchiveService.getArchivedNode(nodeRef); NodeRef archivedNodeRef = VersionServiceImplTest.this.nodeArchiveService.getArchivedNode(nodeRef);

View File

@@ -32,8 +32,7 @@ import javax.transaction.UserTransaction;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
@@ -157,9 +156,9 @@ public class VersionCounterServiceTest extends TestCase
@Override @Override
public void run() public void run()
{ {
TransactionWork<Object> versionWork = new TransactionWork<Object>() RetryingTransactionCallback<Object> versionWork = new RetryingTransactionCallback<Object>()
{ {
public Object doWork() throws Exception public Object execute() throws Exception
{ {
// wait for all other threads to enter into their transactions // wait for all other threads to enter into their transactions
startSignal.countDown(); startSignal.countDown();
@@ -174,7 +173,7 @@ public class VersionCounterServiceTest extends TestCase
}; };
try try
{ {
TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, versionWork, false); transactionService.getRetryingTransactionHelper().doInTransaction(versionWork, false);
error = null; error = null;
} }
catch (Throwable e) catch (Throwable e)

View File

@@ -43,7 +43,7 @@ import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.security.authority.AuthorityDAO; import org.alfresco.repo.security.authority.AuthorityDAO;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor; import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMDifference; import org.alfresco.service.cmr.avmsync.AVMDifference;
@@ -281,13 +281,14 @@ public class WorkflowInterpreter extends AbstractLifecycleBean
{ {
public String doWork() throws Exception public String doWork() throws Exception
{ {
return TransactionUtil.executeInUserTransaction(transactionService, new TransactionUtil.TransactionWork<String>() RetryingTransactionCallback<String> txnWork = new RetryingTransactionCallback<String>()
{ {
public String doWork() throws Exception public String execute() throws Exception
{ {
return executeCommand(line); return executeCommand(line);
} }
}); };
return transactionService.getRetryingTransactionHelper().doInTransaction(txnWork);
} }
}, username); }, username);
} }

View File

@@ -24,7 +24,7 @@
*/ */
package org.alfresco.repo.workflow.jbpm; package org.alfresco.repo.workflow.jbpm;
import org.alfresco.repo.transaction.TransactionUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.jbpm.JbpmConfiguration; import org.jbpm.JbpmConfiguration;
import org.jbpm.job.Job; import org.jbpm.job.Job;
import org.jbpm.job.executor.JobExecutorThread; import org.jbpm.job.executor.JobExecutorThread;
@@ -41,14 +41,6 @@ public class AlfrescoJobExecutorThread extends JobExecutorThread
/** /**
* Constructor * Constructor
*
* @param name
* @param jobExecutor
* @param jbpmConfiguration
* @param idleInterval
* @param maxIdleInterval
* @param maxLockTime
* @param maxHistory
*/ */
public AlfrescoJobExecutorThread(String name, AlfrescoJobExecutor jobExecutor, JbpmConfiguration jbpmConfiguration, int idleInterval, int maxIdleInterval, long maxLockTime, int maxHistory) public AlfrescoJobExecutorThread(String name, AlfrescoJobExecutor jobExecutor, JbpmConfiguration jbpmConfiguration, int idleInterval, int maxIdleInterval, long maxLockTime, int maxHistory)
{ {
@@ -56,13 +48,13 @@ public class AlfrescoJobExecutorThread extends JobExecutorThread
this.alfrescoJobExecutor = jobExecutor; this.alfrescoJobExecutor = jobExecutor;
} }
/* (non-Javadoc) /**
* @see org.jbpm.job.executor.JobExecutorThread#executeJob(org.jbpm.job.Job) * {@inheritDoc}
*/ */
@Override @Override
protected void executeJob(Job job) protected void executeJob(Job job)
{ {
TransactionUtil.executeInUserTransaction(alfrescoJobExecutor.getTransactionService(), new TransactionJob(job)); alfrescoJobExecutor.getTransactionService().getRetryingTransactionHelper().doInTransaction(new TransactionJob(job));
} }
/** /**
@@ -70,24 +62,24 @@ public class AlfrescoJobExecutorThread extends JobExecutorThread
* *
* @author davidc * @author davidc
*/ */
private class TransactionJob implements TransactionUtil.TransactionWork<Object> private class TransactionJob implements RetryingTransactionCallback<Object>
{ {
private Job job; private Job job;
/** /**
* Constructor * Constructor
* *
* @param job * @param job the job to execute
*/ */
public TransactionJob(Job job) public TransactionJob(Job job)
{ {
this.job = job; this.job = job;
} }
/* (non-Javadoc) /**
* @see org.alfresco.repo.transaction.TransactionUtil.TransactionWork#doWork() * {@inheritDoc}
*/ */
public Object doWork() throws Throwable public Object execute() throws Throwable
{ {
AlfrescoJobExecutorThread.super.executeJob(job); AlfrescoJobExecutorThread.super.executeJob(job);
return null; return null;