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

java.lang.Object
  extended by org.springframework.webflow.execution.repository.support.AbstractFlowExecutionRepository
      extended by org.springframework.webflow.execution.repository.support.AbstractConversationFlowExecutionRepository
          extended by org.springframework.webflow.execution.repository.support.SimpleFlowExecutionRepository
All Implemented Interfaces:
FlowExecutionRepository

public class SimpleFlowExecutionRepository
extends AbstractConversationFlowExecutionRepository

Conversation manager based flow execution repository that stores exactly one flow execution per conversation.

It is important to note that by default use of this repository does not allow for duplicate submission in conjunction with browser navigational buttons (such as the back button). Specifically, if you attempt to "go back" and resubmit, the continuation id stored on the page in your browser history will not match the continuation id of the flow execution entry and access to the conversation will be disallowed. This is because the continuationId changes on each request to consistently prevent the possibility of duplicate submission (setAlwaysGenerateNewNextKey(boolean)).

This repository is specifically designed to be 'simple': incurring minimal resources and overhead, as only one FlowExecution is stored per conversation. This repository implementation should only be used when you do not have to support browser navigational button use, e.g. you lock down the browser and require that all navigational events to be routed explicitly through Spring Web Flow.

Author:
Erwin Vervaet, Keith Donald

Field Summary
 
Fields inherited from class org.springframework.webflow.execution.repository.support.AbstractConversationFlowExecutionRepository
logger
 
Constructor Summary
SimpleFlowExecutionRepository(FlowExecutionStateRestorer executionStateRestorer, ConversationManager conversationManager)
          Create a new simple repository using given state restorer and conversation manager.
 
Method Summary
protected  java.io.Serializable generateContinuationId(FlowExecution flowExecution)
          Template method used to generate a new continuation id for given flow execution.
 UidGenerator getContinuationIdGenerator()
          Returns the uid generation strategy used to generate continuation identifiers.
 FlowExecution getFlowExecution(FlowExecutionKey key)
          Return the FlowExecution indexed by the provided key.
 FlowExecutionKey getNextKey(FlowExecution flowExecution, FlowExecutionKey previousKey)
          Obtain the "next" flow execution key to be used as the flow execution's persistent identity.
 boolean isAlwaysGenerateNewNextKey()
          Returns whether or not a new flow execution key should always be generated before each put call.
protected  java.io.Serializable parseContinuationId(java.lang.String encodedId)
          Template method to parse the continuation id from the encoded string.
 void putFlowExecution(FlowExecutionKey key, FlowExecution flowExecution)
          Place the FlowExecution in this repository under the provided key.
 void setAlwaysGenerateNewNextKey(boolean alwaysGenerateNewNextKey)
          Sets a flag indicating if a new FlowExecutionKey should always be generated before each put call.
 void setContinuationIdGenerator(UidGenerator continuationIdGenerator)
          Sets the uid generation strategy used to generate unique continuation identifiers for flow execution keys.
 
Methods inherited from class org.springframework.webflow.execution.repository.support.AbstractConversationFlowExecutionRepository
createConversationParameters, generateKey, getContinuationId, getConversation, getConversationId, getConversationManager, getConversationScope, getLock, onBegin, onEnd, parseFlowExecutionKey, putConversationScope, removeFlowExecution
 
Methods inherited from class org.springframework.webflow.execution.repository.support.AbstractFlowExecutionRepository
getExecutionStateRestorer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleFlowExecutionRepository

public SimpleFlowExecutionRepository(FlowExecutionStateRestorer executionStateRestorer,
                                     ConversationManager conversationManager)
Create a new simple repository using given state restorer and conversation manager.

Parameters:
executionStateRestorer - the flow execution state restoration strategy to use
conversationManager - the conversation manager to use
Method Detail

isAlwaysGenerateNewNextKey

public boolean isAlwaysGenerateNewNextKey()
Returns whether or not a new flow execution key should always be generated before each put call. Default is true.


setAlwaysGenerateNewNextKey

public void setAlwaysGenerateNewNextKey(boolean alwaysGenerateNewNextKey)
Sets a 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.


getContinuationIdGenerator

public UidGenerator getContinuationIdGenerator()
Returns the uid generation strategy used to generate continuation identifiers. Defaults to RandomGuidUidGenerator.


setContinuationIdGenerator

public void setContinuationIdGenerator(UidGenerator continuationIdGenerator)
Sets the uid generation strategy used to generate unique continuation identifiers for flow execution keys.


getNextKey

public FlowExecutionKey getNextKey(FlowExecution flowExecution,
                                   FlowExecutionKey previousKey)
Description copied from interface: FlowExecutionRepository
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.

Specified by:
getNextKey in interface FlowExecutionRepository
Overrides:
getNextKey in class AbstractConversationFlowExecutionRepository
Parameters:
flowExecution - the flow execution
previousKey - the current key associated with the flow exection

getFlowExecution

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

Specified by:
getFlowExecution in interface FlowExecutionRepository
Specified by:
getFlowExecution in class AbstractConversationFlowExecutionRepository
Parameters:
key - the flow execution key
Returns:
the flow execution, fully hydrated and ready to signal an event against

putFlowExecution

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

Specified by:
putFlowExecution in interface FlowExecutionRepository
Specified by:
putFlowExecution in class AbstractConversationFlowExecutionRepository
Parameters:
key - the flow execution key
flowExecution - the flow execution

generateContinuationId

protected java.io.Serializable generateContinuationId(FlowExecution flowExecution)
Description copied from class: AbstractConversationFlowExecutionRepository
Template method used to generate a new continuation id for given flow execution. Subclasses must override.

Specified by:
generateContinuationId in class AbstractConversationFlowExecutionRepository
Parameters:
flowExecution - the flow execution
Returns:
the continuation id

parseContinuationId

protected java.io.Serializable parseContinuationId(java.lang.String encodedId)
Description copied from class: AbstractConversationFlowExecutionRepository
Template method to parse the continuation id from the encoded string.

Specified by:
parseContinuationId in class AbstractConversationFlowExecutionRepository
Parameters:
encodedId - the string identifier
Returns:
the parsed continuation id


Copyright © 2009 Spring Framework. All Rights Reserved.