org.springframework.webflow.executor.support
Class RequestPathFlowExecutorArgumentHandler

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

public class RequestPathFlowExecutorArgumentHandler
extends RequestParameterFlowExecutorArgumentHandler

Flow executor argument handler that extracts arguments from the request path and exposes them in the URL path.

This allows for REST-style URLs to launch flows in the general format: http://${host}/${context path}/${dispatcher path}/${flowId}.

For example, the URL http://localhost/springair/reservation/booking would launch a new execution of the booking flow, assuming a context path of /springair and a servlet mapping of /reservation/*.

This also allows for URLs to resume flow executions in the format: http://${host}/${context path}/${dispatcher path}/${key delimiter}/${flowExecutionKey}.

For example, the URL http://localhost/springair/reservation/k/ABC123XYZ would resume flow execution "ABC123XYZ".

Note: this implementation only works with ExternalContext implementations that return valid ExternalContext.getRequestPathInfo() such as the ServletExternalContext. Furthermore, it assumes that the controller handling flow requests is not identified using request path information. For instance, mapping the dispatcher to "*.html" in web.xml would work since in this case the flow controller will be identified as part of the dispatcher name (e.g. "flows.html"). Mapping the dispatcher to "/html/*" in web.xml will not work since that would require the flow controller to be identified by the extra request path information (e.g. "/html/flows").

Author:
Keith Donald

Constructor Summary
RequestPathFlowExecutorArgumentHandler()
           
 
Method Summary
protected  void appendFlowExecutorPath(java.lang.StringBuffer url, ExternalContext context)
          Append the URL path to the flow executor capable of accepting new requests.
 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).
 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.
 java.lang.String extractFlowExecutionKey(ExternalContext context)
          Extract the flow execution key from the external context.
 java.lang.String extractFlowId(ExternalContext context)
          Extracts the flow id from the external context.
 java.lang.String getKeyDelimiter()
          Returns the key delimiter.
 boolean isFlowExecutionKeyPresent(ExternalContext context)
          Returns true if the flow execution key is extractable from the context.
 boolean isFlowIdPresent(ExternalContext context)
          Returns true if the flow id is extractable from the context.
 void setKeyDelimiter(java.lang.String keyDelimiter)
          Sets the delimiter that when present in the requestPathInfo indicates the flowExecutionKey follows in the URL.
 
Methods inherited from class org.springframework.webflow.executor.support.RequestParameterFlowExecutorArgumentHandler
appendQueryParameter, appendQueryParameters, createExternalUrl, extractEventId, findParameter, getParameterValueDelimiter, isEventIdPresent, setParameterValueDelimiter
 
Methods inherited from class org.springframework.webflow.executor.support.FlowExecutorArgumentHandler
applyDefaultFlowId, encodeValue, exposeFlowExecutionContext, getDefaultFlowId, getEventIdArgumentName, getFlowExecutionContextAttributeName, getFlowExecutionKeyArgumentName, getFlowExecutionKeyAttributeName, getFlowIdArgumentName, getUrlEncodingScheme, isRedirectContextRelative, makeRedirectUrlContextRelativeIfNecessary, setDefaultFlowId, setEventIdArgumentName, setFlowExecutionContextAttributeName, setFlowExecutionKeyArgumentName, setFlowExecutionKeyAttributeName, setFlowIdArgumentName, setRedirectContextRelative, setUrlEncodingScheme
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestPathFlowExecutorArgumentHandler

public RequestPathFlowExecutorArgumentHandler()
Method Detail

getKeyDelimiter

public java.lang.String getKeyDelimiter()
Returns the key delimiter. Defaults to "k".

Returns:
the key delimiter

setKeyDelimiter

public void setKeyDelimiter(java.lang.String keyDelimiter)
Sets the delimiter that when present in the requestPathInfo indicates the flowExecutionKey follows in the URL. Defaults to "k".

Parameters:
keyDelimiter - the key delimiter
See Also:
extractFlowExecutionKey(ExternalContext)

isFlowIdPresent

public 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
Overrides:
isFlowIdPresent in class RequestParameterFlowExecutorArgumentHandler
Parameters:
context - the context in which a external user event occured
Returns:
true if extractable, false if not

extractFlowId

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

Specified by:
extractFlowId in interface FlowExecutorArgumentExtractor
Overrides:
extractFlowId in class RequestParameterFlowExecutorArgumentHandler
Parameters:
context - the context in which a external user event occured
Returns:
the extracted flow id

isFlowExecutionKeyPresent

public 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
Overrides:
isFlowExecutionKeyPresent in class RequestParameterFlowExecutorArgumentHandler
Parameters:
context - the context in which a external user event occured
Returns:
true if extractable, false if not

extractFlowExecutionKey

public 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
Overrides:
extractFlowExecutionKey in class RequestParameterFlowExecutorArgumentHandler
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

createFlowDefinitionUrl

public 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
Overrides:
createFlowDefinitionUrl in class RequestParameterFlowExecutorArgumentHandler
Parameters:
flowDefinitionRedirect - the flow definition redirect view selection
context - the external context
Returns:
the relative flow URL path to redirect to

createFlowExecutionUrl

public 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
Overrides:
createFlowExecutionUrl in class RequestParameterFlowExecutorArgumentHandler
Parameters:
flowExecutionKey - the flow execution key
flowExecution - the flow execution
context - the external context
Returns:
the relative conversation URL path
See Also:
FlowExecutionRedirect

appendFlowExecutorPath

protected void appendFlowExecutorPath(java.lang.StringBuffer url,
                                      ExternalContext context)
Description copied from class: RequestParameterFlowExecutorArgumentHandler
Append the URL path to the flow executor capable of accepting new requests.

Overrides:
appendFlowExecutorPath in class RequestParameterFlowExecutorArgumentHandler
Parameters:
url - the url buffer to append to
context - the context of this request


Copyright © 2009 Spring Framework. All Rights Reserved.