From b886482da58e2175dbeeeda29f20f818f72cc479 Mon Sep 17 00:00:00 2001 From: Erwin Vervaet Date: Thu, 29 Mar 2007 11:12:20 +0000 Subject: [PATCH] Polishing: lazy init of FlowExecutionContinuationGroup to avoid calling conversation.lock/unlock from the FlowExecutionRepository. The conversation.lock/unlock methods are now only called from ConversationBackedFlowExecutionLock, which in turn is only called from the flow executor. --- .../ContinuationFlowExecutionRepository.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/continuation/ContinuationFlowExecutionRepository.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/continuation/ContinuationFlowExecutionRepository.java index 3f45a02a..8c7d6651 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/continuation/ContinuationFlowExecutionRepository.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/repository/continuation/ContinuationFlowExecutionRepository.java @@ -183,18 +183,6 @@ public class ContinuationFlowExecutionRepository extends AbstractConversationFlo putConversationScope(key, flowExecution.getConversationScope()); } - protected void onBegin(Conversation conversation) { - // setup a new continuation group for the conversation - FlowExecutionContinuationGroup continuationGroup = new FlowExecutionContinuationGroup(maxContinuations); - conversation.lock(); - try { - conversation.putAttribute(CONTINUATION_GROUP_ATTRIBUTE, continuationGroup); - } - finally { - conversation.unlock(); - } - } - protected Serializable generateContinuationId(FlowExecution flowExecution) { return continuationIdGenerator.generateUid(); } @@ -210,8 +198,17 @@ public class ContinuationFlowExecutionRepository extends AbstractConversationFlo * @return the continuation group */ FlowExecutionContinuationGroup getContinuationGroup(FlowExecutionKey key) { + Conversation conversation = getConversation(key); FlowExecutionContinuationGroup group = - (FlowExecutionContinuationGroup)getConversation(key).getAttribute(CONTINUATION_GROUP_ATTRIBUTE); + (FlowExecutionContinuationGroup)conversation.getAttribute(CONTINUATION_GROUP_ATTRIBUTE); + if (group == null) { + // setup a new continuation group for the conversation + // no need to synchronize here since this code will only be executed + // during the launch of a new flow execution, at which time the + // key has not yet been communicated to any other threads + group = new FlowExecutionContinuationGroup(maxContinuations); + conversation.putAttribute(CONTINUATION_GROUP_ATTRIBUTE, group); + } return group; }