org.springframework.webflow.execution.repository
Interface FlowExecutionRepository

All Known Implementing Classes:
AbstractConversationFlowExecutionRepository, AbstractFlowExecutionRepository, ClientContinuationFlowExecutionRepository, ContinuationFlowExecutionRepository, SimpleFlowExecutionRepository

public interface FlowExecutionRepository

Central subsystem interface responsible for the saving and restoring of flow executions, where each flow execution represents a state of an active flow definition.

Flow execution repositories are responsible for managing the storage, restoration and removal of flow executions launched by clients of the Spring Web Flow system.

When placed in a repository a FlowExecution object representing the state of a flow at a point in time is indexed under a unique FlowExecutionKey.

Author:
Erwin Vervaet, Keith Donald
See Also:
FlowExecution, FlowExecutionKey

Method Summary
 FlowExecutionKey generateKey(FlowExecution flowExecution)
          Generate a unique flow execution key to be used as the persistent identifier of the flow execution.
 FlowExecution getFlowExecution(FlowExecutionKey key)
          Return the FlowExecution indexed by the provided key.
 FlowExecutionLock getLock(FlowExecutionKey key)
          Return the lock for the flow execution, allowing for the lock to be acquired or released.
 FlowExecutionKey getNextKey(FlowExecution flowExecution, FlowExecutionKey previousKey)
          Obtain the "next" flow execution key to be used as the flow execution's persistent identity.
 FlowExecutionKey parseFlowExecutionKey(java.lang.String encodedKey)
          Parse the string-encoded flow execution key into its object form.
 void putFlowExecution(FlowExecutionKey key, FlowExecution flowExecution)
          Place the FlowExecution in this repository under the provided key.
 void removeFlowExecution(FlowExecutionKey key)
          Remove the flow execution from the repository.
 

Method Detail

generateKey

FlowExecutionKey generateKey(FlowExecution flowExecution)
                             throws FlowExecutionRepositoryException
Generate a unique flow execution key to be used as the persistent identifier of the flow execution. This method should be called after a new flow execution is started and remains active; thus needing to be saved. The FlowExecutionKey is the execution's persistent identity.

Parameters:
flowExecution - the flow execution
Returns:
the flow execution key
Throws:
FlowExecutionRepositoryException - a problem occured generating the key

getNextKey

FlowExecutionKey getNextKey(FlowExecution flowExecution,
                            FlowExecutionKey previousKey)
                            throws FlowExecutionRepositoryException
Obtain the "next" flow execution key to be used as the flow execution's persistent identity. This method should be called after a existing flow execution has resumed and remains active; thus needing to be updated. This repository may choose to return the previous key or generate a new key.

Parameters:
flowExecution - the flow execution
previousKey - the current key associated with the flow exection
Throws:
FlowExecutionRepositoryException - a problem occured generating the key

getLock

FlowExecutionLock getLock(FlowExecutionKey key)
                          throws FlowExecutionRepositoryException
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();
 }
 

Parameters:
key - the identifier of the flow execution to lock
Returns:
the lock
Throws:
FlowExecutionRepositoryException - a problem occured accessing the lock object

getFlowExecution

FlowExecution getFlowExecution(FlowExecutionKey key)
                               throws FlowExecutionRepositoryException
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 aquire the lock for the keyed flow execution.

Parameters:
key - the flow execution key
Returns:
the flow execution, fully hydrated and ready to signal an event against
Throws:
FlowExecutionRepositoryException - if no flow execution was indexed with the key provided

putFlowExecution

void putFlowExecution(FlowExecutionKey key,
                      FlowExecution flowExecution)
                      throws FlowExecutionRepositoryException
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 aquire the lock for the keyed flow execution.

Parameters:
key - the flow execution key
flowExecution - the flow execution
Throws:
FlowExecutionRepositoryException - the flow execution could not be stored

removeFlowExecution

void removeFlowExecution(FlowExecutionKey key)
                         throws FlowExecutionRepositoryException
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 aquire the lock for the keyed flow execution.

Parameters:
key - the flow execution key
Throws:
FlowExecutionRepositoryException - the flow execution could not be removed.

parseFlowExecutionKey

FlowExecutionKey parseFlowExecutionKey(java.lang.String encodedKey)
                                       throws FlowExecutionRepositoryException
Parse the string-encoded flow execution key into its object form. Essentially, the reverse of FlowExecutionKey.toString().

Parameters:
encodedKey - the string encoded key
Returns:
the parsed flow execution key, the persistent identifier for exactly one flow execution
Throws:
FlowExecutionRepositoryException


Copyright © 2004-2007. All Rights Reserved.