org.springframework.webflow.executor.support
Class FlowIdMappingArgumentHandlerWrapper

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

public class FlowIdMappingArgumentHandlerWrapper
extends FlowExecutorArgumentHandler

Flow executor argument handler that wraps another argument handler and applies a public to private flow id mapping. This can be used to avoid literal flow ids in URLs that launch flows.

For example, when used in combination with RequestPathFlowExecutorArgumentHandler the url http://localhost/springair/reservation/booking.html would launch a new execution of the booking-flow flow, assuming a context path of /springair, a servlet mapping of /reservation/* and a flow id mapping of booking->booking-flow (the .html suffix would be removed by RequestPathFlowExecutorArgumentHandler.extractFlowId(ExternalContext).

Since:
1.0.2
Author:
Andrej Zachar, Erwin Vervaet
See Also:
RequestParameterFlowExecutorArgumentHandler, RequestPathFlowExecutorArgumentHandler

Constructor Summary
FlowIdMappingArgumentHandlerWrapper()
          Default constructor for bean style usage.
 
Method Summary
 void addMapping(java.lang.String publicFlowId, java.lang.String privateFlowId)
          Add a flow id mapping, overwriting any previous mapping for the same flow ids.
 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.
 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 extractEventId(ExternalContext context)
          Extract the flow execution event id from the external context.
 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.
 FlowExecutorArgumentHandler getArgumentHandler()
          Returns the wrapped argument handler.
protected  java.util.Properties getMappings()
          Returns the public-to-private flow id mappings in use.
 boolean isEventIdPresent(ExternalContext context)
          Returns true if the event id is extractable from the context.
 boolean isFallback()
          Should we fall back to the flow id extracted by the wrapped argument handler if no mapping is defined for a flow id? Default is true.
 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 setArgumentHandler(FlowExecutorArgumentHandler argumentHandler)
          Set the wrapped argument handler.
 void setFallback(boolean fallback)
          Set whether or not to fall back on the flow id extracted by the wrapped argument handler if no mapping is defined for a flow id.
 void setMappings(java.util.Properties mappings)
          Set the mappings between client-submitted flow identifiers and internal flow identifiers.
 
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

FlowIdMappingArgumentHandlerWrapper

public FlowIdMappingArgumentHandlerWrapper()
Default constructor for bean style usage.

See Also:
setArgumentHandler(FlowExecutorArgumentHandler), setMappings(Properties), setFallback(boolean)
Method Detail

getArgumentHandler

public FlowExecutorArgumentHandler getArgumentHandler()
Returns the wrapped argument handler.


setArgumentHandler

public void setArgumentHandler(FlowExecutorArgumentHandler argumentHandler)
Set the wrapped argument handler.


getMappings

protected java.util.Properties getMappings()
Returns the public-to-private flow id mappings in use.


setMappings

public void setMappings(java.util.Properties mappings)
Set the mappings between client-submitted flow identifiers and internal flow identifiers. Overwrites any previous mappings.

Parameters:
mappings - the public to private flow id mappings

addMapping

public void addMapping(java.lang.String publicFlowId,
                       java.lang.String privateFlowId)
Add a flow id mapping, overwriting any previous mapping for the same flow ids.

Parameters:
publicFlowId - how the flow will be identified publically (to web clients)
privateFlowId - how the flow is identified internally (in the flow definition registry)

isFallback

public boolean isFallback()
Should we fall back to the flow id extracted by the wrapped argument handler if no mapping is defined for a flow id? Default is true.


setFallback

public void setFallback(boolean fallback)
Set whether or not to fall back on the flow id extracted by the wrapped argument handler if no mapping is defined for a flow id. Default is true. When false an exception is thrown when there is a mapping failure.


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
Specified by:
isFlowIdPresent in class FlowExecutorArgumentHandler
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)
                               throws FlowExecutorArgumentExtractionException
Description copied from interface: FlowExecutorArgumentExtractor
Extracts the flow id from the external context.

Specified by:
extractFlowId in interface FlowExecutorArgumentExtractor
Specified by:
extractFlowId in class FlowExecutorArgumentHandler
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 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
Specified by:
isFlowExecutionKeyPresent in class FlowExecutorArgumentHandler
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
Specified by:
extractFlowExecutionKey in class FlowExecutorArgumentHandler
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 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
Specified by:
isEventIdPresent in class FlowExecutorArgumentHandler
Parameters:
context - the context in which a external user event occured
Returns:
true if extractable, false if not

extractEventId

public 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
Specified by:
extractEventId in class FlowExecutorArgumentHandler
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

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
Specified by:
createFlowDefinitionUrl in class FlowExecutorArgumentHandler
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
Specified by:
createFlowExecutionUrl in class FlowExecutorArgumentHandler
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 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
Specified by:
createExternalUrl in class FlowExecutorArgumentHandler
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


Copyright © 2004-2007. All Rights Reserved.