org.springframework.webflow.executor.support
Class FlowExecutorArgumentHandler

java.lang.Object
  extended by org.springframework.webflow.executor.support.FlowExecutorArgumentHandler
All Implemented Interfaces:
FlowExecutorArgumentExposer, FlowExecutorArgumentExtractor
Direct Known Subclasses:
FlowIdMappingArgumentHandlerWrapper, RequestParameterFlowExecutorArgumentHandler

public abstract class FlowExecutorArgumentHandler
extends java.lang.Object
implements FlowExecutorArgumentExtractor, FlowExecutorArgumentExposer

Abstract base class for objects handling FlowExecutor arguments. This class combines the two argument handling responsabilities of (extraction and exposing) and makes sure they are consistent, i.e. that exposed arguments can later be extracted again.

All argument names are configurable. Common convenience functionality is also provided, e.g. a default flow id, URL encoding and dealing with relative URLs. Subclasses are responsible for taking these settings into account when implementing actual argument extraction and exposing behavior.

Author:
Keith Donald, Erwin Vervaet
See Also:
FlowExecutorArgumentExtractor, FlowExecutorArgumentExposer

Constructor Summary
FlowExecutorArgumentHandler()
           
 
Method Summary
protected  java.lang.String applyDefaultFlowId(java.lang.String extractedFlowId)
          Apply the configured default flow id to given extracted flow id.
abstract  java.lang.String createExternalUrl(ExternalRedirect redirect, java.lang.String flowExecutionKey, ExternalContext context)
          Create a URL path that when redirected to communicates with an external system outside of Spring Web Flow.
abstract  java.lang.String createFlowDefinitionUrl(FlowDefinitionRedirect flowDefinitionRedirect, ExternalContext context)
          Create a URL that when redirected to launches a entirely new execution of a flow definition (starts a new conversation).
abstract  java.lang.String createFlowExecutionUrl(java.lang.String flowExecutionKey, FlowExecutionContext flowExecution, ExternalContext context)
          Create a URL path that when redirected to renders the current (or last) view selection made by the flow execution identified by the flow execution key.
protected  java.lang.String encodeValue(java.lang.Object value)
          URL-encode the given input object with the configured encoding scheme.
 void exposeFlowExecutionContext(java.lang.String flowExecutionKey, FlowExecutionContext context, java.util.Map model)
          Expose the flow execution context and it's key in given model map.
abstract  java.lang.String extractEventId(ExternalContext context)
          Extract the flow execution event id from the external context.
abstract  java.lang.String extractFlowExecutionKey(ExternalContext context)
          Extract the flow execution key from the external context.
abstract  java.lang.String extractFlowId(ExternalContext context)
          Extracts the flow id from the external context.
 java.lang.String getDefaultFlowId()
          Returns the default flowId argument value.
 java.lang.String getEventIdArgumentName()
          Returns the event id argument name, used to signal what user action happened within a paused flow execution.
 java.lang.String getFlowExecutionContextAttributeName()
          Returns the flow execution context attribute name.
 java.lang.String getFlowExecutionKeyArgumentName()
          Returns the flow execution key argument name, used to request that an executing conversation resumes.
 java.lang.String getFlowExecutionKeyAttributeName()
          Returns the flow execution key attribute name, used as a model attribute for identifying the executing flow being participated in.
 java.lang.String getFlowIdArgumentName()
          Returns the flow id argument name, used to request a flow to launch.
 java.lang.String getUrlEncodingScheme()
          Returns the url encoding scheme to be used to encode URLs built by this argument handler.
abstract  boolean isEventIdPresent(ExternalContext context)
          Returns true if the event id is extractable from the context.
abstract  boolean isFlowExecutionKeyPresent(ExternalContext context)
          Returns true if the flow execution key is extractable from the context.
abstract  boolean isFlowIdPresent(ExternalContext context)
          Returns true if the flow id is extractable from the context.
 boolean isRedirectContextRelative()
          Return whether to interpret a given redirect URL that starts with a slash ("/") as relative to the current ServletContext, i.e.
protected  java.lang.String makeRedirectUrlContextRelativeIfNecessary(java.lang.String url, ExternalContext context)
          Make given redirect URL context relative if necessary.
 void setDefaultFlowId(java.lang.String defaultFlowId)
          Sets the default flowId argument value.
 void setEventIdArgumentName(java.lang.String eventIdArgumentName)
          Sets the event id argument name, used to signal what user action happened within a paused flow execution.
 void setFlowExecutionContextAttributeName(java.lang.String flowExecutionContextAttributeName)
          Sets the flow execution context attribute name.
 void setFlowExecutionKeyArgumentName(java.lang.String flowExecutionKeyArgumentName)
          Sets the flow execution key argument name, used to request that an executing conversation resumes.
 void setFlowExecutionKeyAttributeName(java.lang.String flowExecutionKeyAttributeName)
          Sets the flow execution key attribute name, used as a model attribute for identifying the current state of the executing flow being participated in (typically used by view templates during rendering).
 void setFlowIdArgumentName(java.lang.String flowIdArgumentName)
          Sets the flow id argument name, used to request a flow to launch.
 void setRedirectContextRelative(boolean redirectContextRelative)
          Set whether to interpret a given redirect URL that starts with a slash ("/") as relative to the current ServletContext, i.e.
 void setUrlEncodingScheme(java.lang.String urlEncodingScheme)
          Set the url encoding scheme to be used to encode URLs built by this argument handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FlowExecutorArgumentHandler

public FlowExecutorArgumentHandler()
Method Detail

getFlowIdArgumentName

public java.lang.String getFlowIdArgumentName()
Returns the flow id argument name, used to request a flow to launch.


setFlowIdArgumentName

public void setFlowIdArgumentName(java.lang.String flowIdArgumentName)
Sets the flow id argument name, used to request a flow to launch.


getFlowExecutionKeyArgumentName

public java.lang.String getFlowExecutionKeyArgumentName()
Returns the flow execution key argument name, used to request that an executing conversation resumes.


setFlowExecutionKeyArgumentName

public void setFlowExecutionKeyArgumentName(java.lang.String flowExecutionKeyArgumentName)
Sets the flow execution key argument name, used to request that an executing conversation resumes.


getEventIdArgumentName

public java.lang.String getEventIdArgumentName()
Returns the event id argument name, used to signal what user action happened within a paused flow execution.


setEventIdArgumentName

public void setEventIdArgumentName(java.lang.String eventIdArgumentName)
Sets the event id argument name, used to signal what user action happened within a paused flow execution.


getDefaultFlowId

public java.lang.String getDefaultFlowId()
Returns the default flowId argument value. If no flow id argument is provided, the default acts as a fallback. Defaults to null.


setDefaultFlowId

public void setDefaultFlowId(java.lang.String defaultFlowId)
Sets the default flowId argument value.

This value will be used if no flowId argument value can be extracted from the request by the extractFlowId(ExternalContext) operation.


getFlowExecutionKeyAttributeName

public java.lang.String getFlowExecutionKeyAttributeName()
Returns the flow execution key attribute name, used as a model attribute for identifying the executing flow being participated in.


setFlowExecutionKeyAttributeName

public void setFlowExecutionKeyAttributeName(java.lang.String flowExecutionKeyAttributeName)
Sets the flow execution key attribute name, used as a model attribute for identifying the current state of the executing flow being participated in (typically used by view templates during rendering).


getFlowExecutionContextAttributeName

public java.lang.String getFlowExecutionContextAttributeName()
Returns the flow execution context attribute name.


setFlowExecutionContextAttributeName

public void setFlowExecutionContextAttributeName(java.lang.String flowExecutionContextAttributeName)
Sets the flow execution context attribute name.


getUrlEncodingScheme

public java.lang.String getUrlEncodingScheme()
Returns the url encoding scheme to be used to encode URLs built by this argument handler. Defaults to "UTF-8".


setUrlEncodingScheme

public void setUrlEncodingScheme(java.lang.String urlEncodingScheme)
Set the url encoding scheme to be used to encode URLs built by this argument handler. Defaults to "UTF-8".


setRedirectContextRelative

public void setRedirectContextRelative(boolean redirectContextRelative)
Set whether to interpret a given redirect URL that starts with a slash ("/") as relative to the current ServletContext, i.e. as relative to the web application root.

Default is "true": A redirect URL that starts with a slash will be interpreted as relative to the web application root, i.e. the context path will be prepended to the URL.


isRedirectContextRelative

public boolean isRedirectContextRelative()
Return whether to interpret a given redirect URL that starts with a slash ("/") as relative to the current ServletContext, i.e. as relative to the web application root.


isFlowIdPresent

public abstract boolean isFlowIdPresent(ExternalContext context)
Description copied from interface: FlowExecutorArgumentExtractor
Returns true if the flow id is extractable from the context.

Specified by:
isFlowIdPresent in interface FlowExecutorArgumentExtractor
Parameters:
context - the context in which a external user event occured
Returns:
true if extractable, false if not

extractFlowId

public abstract java.lang.String extractFlowId(ExternalContext context)
                                        throws FlowExecutorArgumentExtractionException
Description copied from interface: FlowExecutorArgumentExtractor
Extracts the flow id from the external context.

Specified by:
extractFlowId in interface FlowExecutorArgumentExtractor
Parameters:
context - the context in which a external user event occured
Returns:
the extracted flow id
Throws:
FlowExecutorArgumentExtractionException - if the flow id could not be extracted

isFlowExecutionKeyPresent

public abstract boolean isFlowExecutionKeyPresent(ExternalContext context)
Description copied from interface: FlowExecutorArgumentExtractor
Returns true if the flow execution key is extractable from the context.

Specified by:
isFlowExecutionKeyPresent in interface FlowExecutorArgumentExtractor
Parameters:
context - the context in which a external user event occured
Returns:
true if extractable, false if not

extractFlowExecutionKey

public abstract java.lang.String extractFlowExecutionKey(ExternalContext context)
                                                  throws FlowExecutorArgumentExtractionException
Description copied from interface: FlowExecutorArgumentExtractor
Extract the flow execution key from the external context.

Specified by:
extractFlowExecutionKey in interface FlowExecutorArgumentExtractor
Parameters:
context - the context in which the external user event occured
Returns:
the obtained flow execution key
Throws:
FlowExecutorArgumentExtractionException - if the flow execution key could not be extracted

isEventIdPresent

public abstract boolean isEventIdPresent(ExternalContext context)
Description copied from interface: FlowExecutorArgumentExtractor
Returns true if the event id is extractable from the context.

Specified by:
isEventIdPresent in interface FlowExecutorArgumentExtractor
Parameters:
context - the context in which a external user event occured
Returns:
true if extractable, false if not

extractEventId

public abstract java.lang.String extractEventId(ExternalContext context)
                                         throws FlowExecutorArgumentExtractionException
Description copied from interface: FlowExecutorArgumentExtractor
Extract the flow execution event id from the external context.

This method should only be called if a FlowExecutionKey was successfully extracted, indicating a request to resume a flow execution.

Specified by:
extractEventId in interface FlowExecutorArgumentExtractor
Parameters:
context - the context in which a external user event occured
Returns:
the event id
Throws:
FlowExecutorArgumentExtractionException - if the event id could not be extracted

exposeFlowExecutionContext

public void exposeFlowExecutionContext(java.lang.String flowExecutionKey,
                                       FlowExecutionContext context,
                                       java.util.Map model)
Description copied from interface: FlowExecutorArgumentExposer
Expose the flow execution context and it's key in given model map.

Specified by:
exposeFlowExecutionContext in interface FlowExecutorArgumentExposer
Parameters:
flowExecutionKey - the flow execution key (may be null if the conversation has ended)
context - the flow execution context
model - the model map

createFlowDefinitionUrl

public abstract java.lang.String createFlowDefinitionUrl(FlowDefinitionRedirect flowDefinitionRedirect,
                                                         ExternalContext context)
Description copied from interface: FlowExecutorArgumentExposer
Create a URL that when redirected to launches a entirely new execution of a flow definition (starts a new conversation). Used to support the restart flow and redirect to flow use cases.

Specified by:
createFlowDefinitionUrl in interface FlowExecutorArgumentExposer
Parameters:
flowDefinitionRedirect - the flow definition redirect view selection
context - the external context
Returns:
the relative flow URL path to redirect to

createFlowExecutionUrl

public abstract java.lang.String createFlowExecutionUrl(java.lang.String flowExecutionKey,
                                                        FlowExecutionContext flowExecution,
                                                        ExternalContext context)
Description copied from interface: FlowExecutorArgumentExposer
Create a URL path that when redirected to renders the current (or last) view selection made by the flow execution identified by the flow execution key. Used to support the flow execution redirect use case.

Specified by:
createFlowExecutionUrl in interface FlowExecutorArgumentExposer
Parameters:
flowExecutionKey - the flow execution key
flowExecution - the flow execution
context - the external context
Returns:
the relative conversation URL path
See Also:
FlowExecutionRedirect

createExternalUrl

public abstract java.lang.String createExternalUrl(ExternalRedirect redirect,
                                                   java.lang.String flowExecutionKey,
                                                   ExternalContext context)
Description copied from interface: FlowExecutorArgumentExposer
Create a URL path that when redirected to communicates with an external system outside of Spring Web Flow.

Specified by:
createExternalUrl in interface FlowExecutorArgumentExposer
Parameters:
redirect - the external redirect request
flowExecutionKey - the flow execution key to send through the redirect (optional)
context - the external context
Returns:
the external URL

applyDefaultFlowId

protected java.lang.String applyDefaultFlowId(java.lang.String extractedFlowId)
Apply the configured default flow id to given extracted flow id.

Parameters:
extractedFlowId - the extracted flow id, could be null if non was available in the external context
Returns:
the extracted flow id if not empty, the default flow id otherwise (which could still be null if not set)
See Also:
getDefaultFlowId()

encodeValue

protected java.lang.String encodeValue(java.lang.Object value)
URL-encode the given input object with the configured encoding scheme.

Parameters:
value - the unencoded value
Returns:
the encoded output String
See Also:
getUrlEncodingScheme()

makeRedirectUrlContextRelativeIfNecessary

protected java.lang.String makeRedirectUrlContextRelativeIfNecessary(java.lang.String url,
                                                                     ExternalContext context)
Make given redirect URL context relative if necessary. If the URL starts with a slash ("/") it will be made relative to the current ServletContext, i.e. relative to the web application root.

Parameters:
url - the original URL
context - the external context
Returns:
the processed URL
See Also:
isRedirectContextRelative()


Copyright © 2009 Spring Framework. All Rights Reserved.