mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Make the cache objects used by the Action Tracking Service immutable
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22382 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -388,8 +388,12 @@ public class ActionTrackingServiceImpl implements ActionTrackingService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since it is, update the cancelled flag on it
|
// Create a new copy of the details, this time with
|
||||||
details.requestCancel();
|
// the cancel flag set
|
||||||
|
details = new ExecutionDetails(
|
||||||
|
details.getExecutionSummary(), details.getPersistedActionRef(),
|
||||||
|
details.getRunningOn(), details.getStartedAt(), true
|
||||||
|
);
|
||||||
|
|
||||||
// Save the flag to the cache
|
// Save the flag to the cache
|
||||||
executingActionsCache.put(actionKey, details);
|
executingActionsCache.put(actionKey, details);
|
||||||
|
@@ -752,13 +752,16 @@ public class ActionTrackingServiceImplTest extends TestCase
|
|||||||
|
|
||||||
// Get the updated key, and check
|
// Get the updated key, and check
|
||||||
key3 = ActionTrackingServiceImpl.generateCacheKey(sleepAction3);
|
key3 = ActionTrackingServiceImpl.generateCacheKey(sleepAction3);
|
||||||
|
ExecutionSummary s3 = ActionTrackingServiceImpl.buildExecutionSummary(key3);
|
||||||
|
|
||||||
assertEquals(false, actionTrackingService.isCancellationRequested(sleepAction3));
|
assertEquals(false, actionTrackingService.isCancellationRequested(sleepAction3));
|
||||||
|
assertEquals(false, actionTrackingService.getExecutionDetails(s3).isCancelRequested());
|
||||||
assertNotNull(executingActionsCache.get(key3));
|
assertNotNull(executingActionsCache.get(key3));
|
||||||
|
|
||||||
actionTrackingService.requestActionCancellation(sleepAction3);
|
actionTrackingService.requestActionCancellation(sleepAction3);
|
||||||
|
|
||||||
assertEquals(true, actionTrackingService.isCancellationRequested(sleepAction3));
|
assertEquals(true, actionTrackingService.isCancellationRequested(sleepAction3));
|
||||||
|
assertEquals(true, actionTrackingService.getExecutionDetails(s3).isCancelRequested());
|
||||||
assertNotNull(executingActionsCache.get(key3));
|
assertNotNull(executingActionsCache.get(key3));
|
||||||
|
|
||||||
// Have it finish sleeping, will have been cancelled
|
// Have it finish sleeping, will have been cancelled
|
||||||
|
@@ -38,12 +38,18 @@ public class ExecutionDetails implements Serializable {
|
|||||||
* we don't need to also hold a 2nd copy of it
|
* we don't need to also hold a 2nd copy of it
|
||||||
*/
|
*/
|
||||||
private transient ExecutionSummary executionSummary;
|
private transient ExecutionSummary executionSummary;
|
||||||
private NodeRef persistedActionRef;
|
|
||||||
private String runningOn;
|
|
||||||
private Date startedAt;
|
|
||||||
private boolean cancelRequested;
|
|
||||||
|
|
||||||
public ExecutionDetails() {}
|
private final NodeRef persistedActionRef;
|
||||||
|
private final String runningOn;
|
||||||
|
private final Date startedAt;
|
||||||
|
private final boolean cancelRequested;
|
||||||
|
|
||||||
|
public ExecutionDetails() {
|
||||||
|
persistedActionRef = null;
|
||||||
|
runningOn = null;
|
||||||
|
startedAt = null;
|
||||||
|
cancelRequested = false;
|
||||||
|
}
|
||||||
|
|
||||||
public ExecutionDetails(ExecutionSummary executionSummary,
|
public ExecutionDetails(ExecutionSummary executionSummary,
|
||||||
NodeRef persistedActionRef, String runningOn, Date startedAt,
|
NodeRef persistedActionRef, String runningOn, Date startedAt,
|
||||||
@@ -109,7 +115,4 @@ public class ExecutionDetails implements Serializable {
|
|||||||
public boolean isCancelRequested() {
|
public boolean isCancelRequested() {
|
||||||
return cancelRequested;
|
return cancelRequested;
|
||||||
}
|
}
|
||||||
public void requestCancel() {
|
|
||||||
cancelRequested = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -28,12 +28,12 @@ package org.alfresco.service.cmr.action;
|
|||||||
* @author Nick Burch
|
* @author Nick Burch
|
||||||
*/
|
*/
|
||||||
public class ExecutionSummary {
|
public class ExecutionSummary {
|
||||||
private String actionType;
|
private final String actionType;
|
||||||
private String actionId;
|
private final String actionId;
|
||||||
private int executionInstance;
|
private final int executionInstance;
|
||||||
|
|
||||||
public ExecutionSummary(String actionType, String actionId,
|
public ExecutionSummary(final String actionType, final String actionId,
|
||||||
int executionInstance) {
|
final int executionInstance) {
|
||||||
this.actionType = actionType;
|
this.actionType = actionType;
|
||||||
this.actionId = actionId;
|
this.actionId = actionId;
|
||||||
this.executionInstance = executionInstance;
|
this.executionInstance = executionInstance;
|
||||||
|
Reference in New Issue
Block a user