org.springframework.webflow.execution.repository.continuation
Class ClientContinuationFlowExecutionRepository

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.continuation.ClientContinuationFlowExecutionRepository
All Implemented Interfaces:
FlowExecutionRepository

public class ClientContinuationFlowExecutionRepository
extends AbstractConversationFlowExecutionRepository

Stores flow execution state client side, requiring no use of server-side state.

More specifically, instead of putting FlowExecution objects in a server-side store this repository encodes them directly into the continuationId of the generated FlowExecutionKey. When asked to load a flow execution by its key this repository decodes the serialized continuationId, restoring the FlowExecution object at the state it was in when encoded.

Note: currently this repository implementation does not by default support conversation management. This has two consequences. First, there is no conversation invalidation after completion, which enables automatic prevention of duplicate submission after a conversation has completed. Secondly, The contents of conversation scope will not be maintained across requests. Support for these features requires tracking active conversations using a conversation service backed by some centralized storage medium like a database table. If you want to have proper conversation management, configure this class with an appropriate conversation manager (the default conversation manager used does nothing).

Warning: storing state (a flow execution continuation) on the client entails a certain security risk. This implementation does not provide a secure way of storing state on the client, so a malicious client could reverse engineer a continuation and get access to possible sensitive data stored in the flow execution. If you need more security and still want to store continuations on the client, subclass this class and override the methods encode(FlowExecution) and decode(String), implementing them with a secure encoding/decoding algorithm, e.g. based on public/private key encryption.

Author:
Keith Donald, Erwin Vervaet
See Also:
Base64

Field Summary
 
Fields inherited from class org.springframework.webflow.execution.repository.support.AbstractConversationFlowExecutionRepository
logger
 
Constructor Summary
ClientContinuationFlowExecutionRepository(FlowExecutionStateRestorer executionStateRestorer)
          Creates a new client continuation repository.
ClientContinuationFlowExecutionRepository(FlowExecutionStateRestorer executionStateRestorer, ConversationManager conversationManager)
          Creates a new client continuation repository.
 
Method Summary
protected  FlowExecutionContinuation decode(java.lang.String encodedContinuation)
          Decode given data, received from the client, and return the corresponding flow execution object.
protected  java.io.Serializable encode(FlowExecution flowExecution)
          Encode given flow execution object into data that can be stored on the client.
protected  java.io.Serializable generateContinuationId(FlowExecution flowExecution)
          Template method used to generate a new continuation id for given flow execution.
protected  FlowExecutionContinuationFactory getContinuationFactory()
          Returns the continuation factory in use by this repository.
 FlowExecution getFlowExecution(FlowExecutionKey key)
          Return the FlowExecution indexed by the provided key.
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 setContinuationFactory(FlowExecutionContinuationFactory continuationFactory)
          Sets the continuation factory used by this repository.
 
Methods inherited from class org.springframework.webflow.execution.repository.support.AbstractConversationFlowExecutionRepository
createConversationParameters, generateKey, getContinuationId, getConversation, getConversationId, getConversationManager, getConversationScope, getLock, getNextKey, 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

ClientContinuationFlowExecutionRepository

public ClientContinuationFlowExecutionRepository(FlowExecutionStateRestorer executionStateRestorer)
Creates a new client continuation repository. Uses a 'no op' conversation manager by default.

Parameters:
executionStateRestorer - the transient flow execution state restorer

ClientContinuationFlowExecutionRepository

public ClientContinuationFlowExecutionRepository(FlowExecutionStateRestorer executionStateRestorer,
                                                 ConversationManager conversationManager)
Creates a new client continuation repository. Use this contructor when you want to use a particular conversation manager, e.g. one that does proper conversation management.

Parameters:
executionStateRestorer - the transient flow execution state restorer
conversationManager - the conversation manager for managing centralized conversational state
Method Detail

getContinuationFactory

protected FlowExecutionContinuationFactory getContinuationFactory()
Returns the continuation factory in use by this repository.


setContinuationFactory

public void setContinuationFactory(FlowExecutionContinuationFactory continuationFactory)
Sets the continuation factory used by this repository.


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 final 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 final 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

encode

protected java.io.Serializable encode(FlowExecution flowExecution)
Encode given flow execution object into data that can be stored on the client.

Subclasses can override this to change the encoding algorithm. This class just does a BASE64 encoding of the serialized flow execution.

Parameters:
flowExecution - the flow execution instance
Returns:
the encoded representation

decode

protected FlowExecutionContinuation decode(java.lang.String encodedContinuation)
Decode given data, received from the client, and return the corresponding flow execution object.

Subclasses can override this to change the decoding algorithm. This class just does a BASE64 decoding and then deserializes the flow execution.

Parameters:
encodedContinuation - the encoded flow execution data
Returns:
the decoded flow execution instance


Copyright © 2009 Spring Framework. All Rights Reserved.