org.springframework.webflow.test
Class MockFlowExecutionContext

java.lang.Object
  extended by org.springframework.webflow.test.MockFlowExecutionContext
All Implemented Interfaces:
FlowExecutionContext

public class MockFlowExecutionContext
extends java.lang.Object
implements FlowExecutionContext

A stub implementation of the flow execution context interface.

Author:
Keith Donald
See Also:
FlowExecutionContext

Constructor Summary
MockFlowExecutionContext()
          Creates a new mock flow execution context -- automatically installs a root flow definition and active flow session.
MockFlowExecutionContext(Flow rootFlow)
          Creates a new mock flow execution context for the specified root flow definition.
 
Method Summary
 FlowSession getActiveSession()
          Returns the active flow session of this flow execution.
 MutableAttributeMap getAttributeMap()
          Returns the mutable execution attribute map.
 AttributeMap getAttributes()
          Returns runtime execution attributes that may influence the behavior of flow artifacts, such as states and actions.
 java.lang.String getCaption()
           
 MutableAttributeMap getConversationScope()
          Returns a mutable map for data held in "conversation scope".
 FlowDefinition getDefinition()
          Returns the root flow definition associated with this executing flow.
 MockFlowSession getMockActiveSession()
          Returns the mock active flow session.
 boolean isActive()
          Is the flow execution active?
 void putAttribute(java.lang.String attributeName, java.lang.Object attributeValue)
          Puts a execution attribute into the context.
 void setActiveSession(FlowSession activeSession)
          Sets the mock session to be the active session.
 void setConversationScope(MutableAttributeMap scope)
          Sets flow execution (conversational) scope.
 void setFlow(Flow rootFlow)
          Sets the top-level flow definition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockFlowExecutionContext

public MockFlowExecutionContext()
Creates a new mock flow execution context -- automatically installs a root flow definition and active flow session.


MockFlowExecutionContext

public MockFlowExecutionContext(Flow rootFlow)
Creates a new mock flow execution context for the specified root flow definition.

Method Detail

getCaption

public java.lang.String getCaption()

getDefinition

public FlowDefinition getDefinition()
Description copied from interface: FlowExecutionContext
Returns the root flow definition associated with this executing flow.

A call to this method always returns the same flow definition -- the top-level "root" -- no matter what flow may actually be active (for example, if subflows have been spawned).

Specified by:
getDefinition in interface FlowExecutionContext
Returns:
the root flow definition

isActive

public boolean isActive()
Description copied from interface: FlowExecutionContext
Is the flow execution active?

All methods on an active flow execution context can be called successfully. If the flow execution is not active, a caller cannot access some methods such as FlowExecutionContext.getActiveSession().

Specified by:
isActive in interface FlowExecutionContext
Returns:
true if active, false if the flow execution has terminated

getActiveSession

public FlowSession getActiveSession()
                             throws java.lang.IllegalStateException
Description copied from interface: FlowExecutionContext
Returns the active flow session of this flow execution. The active flow session is the currently executing session -- it may be the "root flow" session, or it may be a subflow session if this flow execution has spawned a subflow.

Specified by:
getActiveSession in interface FlowExecutionContext
Returns:
the active flow session
Throws:
java.lang.IllegalStateException - if this flow execution has not been started at all or if this execution has ended and is no longer actively executing

getConversationScope

public MutableAttributeMap getConversationScope()
Description copied from interface: FlowExecutionContext
Returns a mutable map for data held in "conversation scope". Conversation scope is a data structure that exists for the life of this flow execution and is accessible to all flow sessions.

Specified by:
getConversationScope in interface FlowExecutionContext
Returns:
conversation scope

getAttributes

public AttributeMap getAttributes()
Description copied from interface: FlowExecutionContext
Returns runtime execution attributes that may influence the behavior of flow artifacts, such as states and actions.

Specified by:
getAttributes in interface FlowExecutionContext
Returns:
execution attributes

setFlow

public void setFlow(Flow rootFlow)
Sets the top-level flow definition.


setActiveSession

public void setActiveSession(FlowSession activeSession)
Sets the mock session to be the active session.


setConversationScope

public void setConversationScope(MutableAttributeMap scope)
Sets flow execution (conversational) scope.


getMockActiveSession

public MockFlowSession getMockActiveSession()
Returns the mock active flow session.


getAttributeMap

public MutableAttributeMap getAttributeMap()
Returns the mutable execution attribute map.

Returns:
the execution attribute map

putAttribute

public void putAttribute(java.lang.String attributeName,
                         java.lang.Object attributeValue)
Puts a execution attribute into the context.

Parameters:
attributeName - the attribute name
attributeValue - the attribute value


Copyright © 2004-2007. All Rights Reserved.