org.springframework.webflow.execution.repository.support
Class AbstractFlowExecutionRepository

java.lang.Object
  extended by org.springframework.webflow.execution.repository.support.AbstractFlowExecutionRepository
All Implemented Interfaces:
FlowExecutionKeyFactory, FlowExecutionRepository
Direct Known Subclasses:
AbstractSnapshottingFlowExecutionRepository

public abstract class AbstractFlowExecutionRepository
extends Object
implements FlowExecutionRepository, FlowExecutionKeyFactory

Abstract base class for flow execution repository implementations. Does not make any assumptions about the storage medium used to store active flow executions. Mandates the use of a FlowExecutionStateRestorer, used to rehydrate a flow execution after it has been obtained from storage from resume.

The configured FlowExecutionStateRestorer should be compatible with the chosen FlowExecution implementation and its FlowExecutionFactory.

Author:
Keith Donald, Erwin Vervaet

Method Summary
 boolean getAlwaysGenerateNewNextKey()
          The flag indicating if a new FlowExecutionKey should always be generated before each put call.
 ConversationManager getConversationManager()
          The conversation service to delegate to for managing conversations initiated by this repository.
abstract  FlowExecution getFlowExecution(FlowExecutionKey key)
          Return the FlowExecution indexed by the provided key.
 FlowExecutionKey getKey(FlowExecution execution)
          Get the key to assign to the flow execution.
 FlowExecutionLock getLock(FlowExecutionKey key)
          Return the lock for the flow execution, allowing for the lock to be acquired or released.
 FlowExecutionKey parseFlowExecutionKey(String encodedKey)
          Parse the string-encoded flow execution key into its object form.
abstract  void putFlowExecution(FlowExecution flowExecution)
          Place the FlowExecution in this repository under the provided key.
 void removeFlowExecution(FlowExecution flowExecution)
          Remove the flow execution from the repository.
 void setAlwaysGenerateNewNextKey(boolean alwaysGenerateNewNextKey)
          Sets the flag indicating if a new FlowExecutionKey should always be generated before each put call.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.webflow.execution.FlowExecutionKeyFactory
removeAllFlowExecutionSnapshots, removeFlowExecutionSnapshot, updateFlowExecutionSnapshot
 

Method Detail

getConversationManager

public ConversationManager getConversationManager()
The conversation service to delegate to for managing conversations initiated by this repository.


getAlwaysGenerateNewNextKey

public boolean getAlwaysGenerateNewNextKey()
The flag indicating if a new FlowExecutionKey should always be generated before each put call.


setAlwaysGenerateNewNextKey

public void setAlwaysGenerateNewNextKey(boolean alwaysGenerateNewNextKey)
Sets the flag indicating if a new FlowExecutionKey should always be generated before each put call. By setting this to false a FlowExecution can remain identified by the same key throughout its life.


getKey

public FlowExecutionKey getKey(FlowExecution execution)
Description copied from interface: FlowExecutionKeyFactory
Get the key to assign to the flow execution. This factory simply generates the key to assign, it does not actually perform the key assignment.

Specified by:
getKey in interface FlowExecutionKeyFactory
Parameters:
execution - the flow execution
Returns:
the key to assign to the flow execution

parseFlowExecutionKey

public FlowExecutionKey parseFlowExecutionKey(String encodedKey)
                                       throws FlowExecutionRepositoryException
Description copied from interface: FlowExecutionRepository
Parse the string-encoded flow execution key into its object form. Essentially, the reverse of FlowExecutionKey.toString().

Specified by:
parseFlowExecutionKey in interface FlowExecutionRepository
Parameters:
encodedKey - the string encoded key
Returns:
the parsed flow execution key, the persistent identifier for exactly one flow execution
Throws:
FlowExecutionRepositoryException

getLock

public FlowExecutionLock getLock(FlowExecutionKey key)
                          throws FlowExecutionRepositoryException
Description copied from interface: FlowExecutionRepository
Return the lock for the flow execution, allowing for the lock to be acquired or released. Caution: care should be made not to allow for a deadlock situation. If you acquire a lock make sure you release it when you are done. The general pattern for safely doing work against a locked conversation follows:
 FlowExecutionLock lock = repository.getLock(key);
 lock.lock();
 try {
        FlowExecution execution = repository.getFlowExecution(key);
        // do work
 } finally {
        lock.unlock();
 }
 

Specified by:
getLock in interface FlowExecutionRepository
Parameters:
key - the identifier of the flow execution to lock
Returns:
the lock
Throws:
FlowExecutionRepositoryException - a problem occurred accessing the lock object

removeFlowExecution

public void removeFlowExecution(FlowExecution flowExecution)
                         throws FlowExecutionRepositoryException
Description copied from interface: FlowExecutionRepository
Remove the flow execution from the repository. This should be called when the flow execution ends (is no longer active). Before calling this method, you should acquire the lock for the keyed flow execution.

Specified by:
removeFlowExecution in interface FlowExecutionRepository
Parameters:
flowExecution - the flow execution
Throws:
FlowExecutionRepositoryException - the flow execution could not be removed.

getFlowExecution

public abstract FlowExecution getFlowExecution(FlowExecutionKey key)
                                        throws FlowExecutionRepositoryException
Description copied from interface: FlowExecutionRepository
Return the FlowExecution indexed by the provided key. The returned flow execution represents the restored state of an executing flow from a point in time. This should be called to resume a persistent flow execution. Before calling this method, you should acquire the lock for the keyed flow execution.

Specified by:
getFlowExecution in interface FlowExecutionRepository
Parameters:
key - the flow execution key
Returns:
the flow execution, fully hydrated and ready to resume
Throws:
FlowExecutionRepositoryException - if no flow execution was indexed with the key provided

putFlowExecution

public abstract void putFlowExecution(FlowExecution flowExecution)
                               throws FlowExecutionRepositoryException
Description copied from interface: FlowExecutionRepository
Place the FlowExecution in this repository under the provided key. This should be called to save or update the persistent state of an active (but paused) flow execution. Before calling this method, you should acquire the lock for the keyed flow execution.

Specified by:
putFlowExecution in interface FlowExecutionRepository
Parameters:
flowExecution - the flow execution
Throws:
FlowExecutionRepositoryException - the flow execution could not be stored