Expert Spring MVC and Web Flow

(Dana P.) #1

It stores snapshots of FlowExecutions that represent a stateful user conversation in an
in-memory map. Each map entry key is a conversationId, uniquely identifying a single
ongoing conversation between a client and the Spring Web Flow system. Each map entry
value is an org.springframework.webflow.execution.repository.continuation.Conversation
object, providing the details about one ongoing logical conversation. Each Conversation
object maintains a stack of org.springframework.webflow.execution.repository.continuation.
FlowExecutionContinuations, each continuation representing a restorable state of a conversa-
tion at a point in time. These continuations allow users to go back in their browser successfully
to continue a conversation from a previous point.


SimpleFlowExecutionRepository


This is a trivial implementation that stores single instances of FlowExecutions in an in-memory
map with a much simpler structure than the ContinuationFlowExecutionRepository. It requires
minimal resource requirements, designed to be used when supporting browser navigation
button use is not necessary (as is the case for many intranet applications that lock down the
browser).
In this repository, each map entry key is a conversationIdand each map entry
value is a FlowExecutionEntryobject. The FlowExecutionEntry(which is internal to
SimpleFlowExecutionRepository) consists of the FlowExecution and a unique continuationId
that acts as a token required for accessing the conversation. Because the continuationId
is changed after every transition, Back button use and duplicate form submission are not
supported and will result in a NoSuchConversationContinuationExceptionbeing thrown
consistently each time.


■NoteThis is the default implementation used by RepositoryFlowExecutionStorage.


Stateless FlowExecution Repositories


Stateless repositories do not maintain any internal state, but instead rely on conversational
state to be stored externally—for example, in the database or in a serialized structure sent
from the client. Currently there exists one stateless implementation, org.springframework.
webflow.execution.repository.continuation.ClientContinuationFlowExecutionRepository.


ClientContinuationFlowExecutionRepository


This repository implementation encodes the state of the FlowExecutionContinuationinto the
continuationId, which is written out to the browser in the _flowExecutionIdparameter. On a
subsequent request, that encoded FlowExecutionContinuationis deserialized and resumed.
This implementation requires no server-side state whatsoever, but still reaps all the benefits
of continuations, including proper browser navigational behavior.


CHAPTER 12 ■ADVANCED SPRING WEB FLOW 357
Free download pdf