public interface ExternalContext
This context object provides a normalized interface for internal web flow artifacts to use to reason on and manipulate the state of an external actor calling into SWF to execute flows. It represents the context about a single, external client request to manipulate a flow execution.
The design of this interface was inspired by JSF's own ExternalContext abstraction and shares the same name for
consistency. If a particular external client type does not support all methods defined by this interface, they can
just be implemented as returning an empty map or null
.
Modifier and Type | Method and Description |
---|---|
SharedAttributeMap<java.lang.Object> |
getApplicationMap()
Provides access to the external application map, providing a storage for data local to the current user
application and accessible to both internal and external SWF artifacts.
|
java.lang.String |
getContextPath()
Returns the logical path to the application hosting this external context.
|
java.security.Principal |
getCurrentUser()
Provides access to the user's principal security object.
|
java.lang.String |
getFlowExecutionUrl(java.lang.String flowId,
java.lang.String flowExecutionKey)
Get a flow execution URL for the execution with the provided key.
|
SharedAttributeMap<java.lang.Object> |
getGlobalSessionMap()
Provides access to the global external session map, providing a storage for data globally accross the user
session and accessible to both internal and external SWF artifacts.
|
java.util.Locale |
getLocale()
Returns the client locale.
|
java.lang.Object |
getNativeContext()
Provides access to the context object for the current environment.
|
java.lang.Object |
getNativeRequest()
Provides access to the request object for the current environment.
|
java.lang.Object |
getNativeResponse()
Provides access to the response object for the current environment.
|
MutableAttributeMap<java.lang.Object> |
getRequestMap()
Provides access to the external request attribute map, providing a storage for data local to the current user
request and accessible to both internal and external SWF artifacts.
|
ParameterMap |
getRequestParameterMap()
Provides access to the parameters associated with the user request that led to SWF being called.
|
java.io.Writer |
getResponseWriter()
Get a writer for writing out a response.
|
SharedAttributeMap<java.lang.Object> |
getSessionMap()
Provides access to the external session map, providing a storage for data local to the current user session and
accessible to both internal and external SWF artifacts.
|
boolean |
isAjaxRequest()
Returns true if the current request is an asynchronous Ajax request.
|
boolean |
isResponseAllowed()
Is a render response allowed to be written for this request? Always return false after a response has been
completed.
|
boolean |
isResponseComplete()
Has the response been completed? Response complete status can be achieved by:
Writing out the response and calling
recordResponseComplete() , or
Calling one of the redirect request methods
|
boolean |
isResponseCompleteFlowExecutionRedirect()
Returns true if the response has been completed with flow execution redirect request.
|
void |
recordResponseComplete()
Called by flow artifacts such as View states and end states to indicate they handled the response, typically by
writing out content to the response stream.
|
void |
requestExternalRedirect(java.lang.String location)
Request a redirect to an arbitrary resource location.
|
void |
requestFlowDefinitionRedirect(java.lang.String flowId,
MutableAttributeMap<?> input)
Request that a flow definition redirect be performed by the calling environment.
|
void |
requestFlowExecutionRedirect()
Request that a flow execution redirect be performed by the calling environment.
|
void |
requestRedirectInPopup()
Request that the current redirect requested be sent to the client in a manner that causes the client to issue the
redirect from a popup dialog.
|
java.lang.String getContextPath()
ParameterMap getRequestParameterMap()
MutableAttributeMap<java.lang.Object> getRequestMap()
SharedAttributeMap<java.lang.Object> getSessionMap()
SharedAttributeMap<java.lang.Object> getGlobalSessionMap()
Note: most external context implementations do not distinguish between the concept of a "local" user session
scope and a "global" session scope. The Portlet world does, but not the Servlet for example. In those cases
calling this method returns the same map as calling getSessionMap()
.
SharedAttributeMap<java.lang.Object> getApplicationMap()
boolean isAjaxRequest()
java.lang.String getFlowExecutionUrl(java.lang.String flowId, java.lang.String flowExecutionKey)
flowId
- the flow definition idflowExecutionKey
- the flow execution keyjava.security.Principal getCurrentUser()
java.util.Locale getLocale()
java.lang.Object getNativeContext()
java.lang.Object getNativeRequest()
java.lang.Object getNativeResponse()
java.io.Writer getResponseWriter() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if the response has completed or is not allowedboolean isResponseAllowed()
void requestFlowExecutionRedirect() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if the response has completedisResponseComplete()
void requestFlowDefinitionRedirect(java.lang.String flowId, MutableAttributeMap<?> input) throws java.lang.IllegalStateException
flowId
- the id of the flow definition to redirect toinput
- input to pass the flow; this input is generally encoded the url to launch the flowjava.lang.IllegalStateException
- if the response has completedisResponseComplete()
void requestExternalRedirect(java.lang.String location) throws java.lang.IllegalStateException
location
- the location of the resource to redirect tojava.lang.IllegalStateException
- if the response has completedisResponseComplete()
void requestRedirectInPopup() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if a redirect has not been requestedrequestFlowExecutionRedirect()
,
requestFlowDefinitionRedirect(String, MutableAttributeMap)
,
requestExternalRedirect(String)
void recordResponseComplete()
boolean isResponseComplete()
recordResponseComplete()
, or
getResponseWriter()
,
recordResponseComplete()
,
requestFlowExecutionRedirect()
,
requestFlowDefinitionRedirect(String, MutableAttributeMap)
,
requestExternalRedirect(String)
boolean isResponseCompleteFlowExecutionRedirect()
isResponseComplete()
,
requestFlowExecutionRedirect()