1 /* 2 * Copyright 2002-2006 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.springframework.webflow.execution.repository.support; 17 18 import org.springframework.webflow.conversation.Conversation; 19 import org.springframework.webflow.conversation.ConversationManager; 20 import org.springframework.webflow.execution.repository.FlowExecutionLock; 21 22 /** 23 * A flow execution lock that locks a conversation managed by a 24 * {@link ConversationManager}. 25 * <p> 26 * This implementation ensures multiple threads cannot manipulate the same 27 * conversation at the same time. The locked conversation is the sole gateway to 28 * a flow execution, and a lock on it prevents access to any associated 29 * execution. 30 * 31 * @see ConversationManager 32 * @see Conversation 33 * @see Conversation#lock() 34 * @see Conversation#unlock() 35 * 36 * @author Keith Donald 37 */ 38 class ConversationBackedFlowExecutionLock implements FlowExecutionLock { 39 40 /** 41 * The conversation to lock. 42 */ 43 private Conversation conversation; 44 45 /** 46 * Creates a new conversation-backed flow execution lock. 47 * @param conversation the conversation to lock 48 */ 49 public ConversationBackedFlowExecutionLock(Conversation conversation) { 50 this.conversation = conversation; 51 } 52 53 public void lock() { 54 conversation.lock(); 55 } 56 57 public void unlock() { 58 conversation.unlock(); 59 } 60 }