com.ervacon.springframework.web.servlet.mvc.webflow
Class SimpleWebFlow

java.lang.Object
  extended bycom.ervacon.springframework.web.servlet.mvc.webflow.SimpleWebFlow
All Implemented Interfaces:
org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean, WebFlow

public class SimpleWebFlow
extends java.lang.Object
implements WebFlow, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware

Simple web flow implementation. This class reads a web flow definition conforming to the web flow DTD from a specified resource. This implementation uses JDOM to access the XML flow definition. Several extension hook methods are provided in case a subclass wants to fine tune the behaviour of this class.

A web flow is configured in the Spring application context as a normal bean. Note that this flow implementation is thread safe: all state is initialized when the bean is created by the Spring application context. Once this is done, all state is read only. The modifiable state associated with a flow is stored in a seperate web flow memento that is associated with each active flow used by a client. The client (e.g. a controller implementation) is responsible for correct management of this memento.

Normally you should not use this class directly from within a web application. Instead, you use the provided WebFlowController to use and drive the flow.

Exposed configuration properties

name default description
webFlowResource null Specifies the resource from which the flow definition is loaded.

Author:
Erwin Vervaet
See Also:
WebFlowMemento, WebFlowController

Field Summary
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
SimpleWebFlow()
           
 
Method Summary
 void afterPropertiesSet()
           
 org.springframework.web.servlet.ModelAndView execute(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String state, java.lang.String event, WebFlowMementoStack mementos)
          Execute an event in a state of the web flow.
protected  org.springframework.web.servlet.ModelAndView executeActionState(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.jdom.Element stateDef, WebFlowMementoStack mementos)
          Execute given action state.
protected  org.springframework.web.servlet.ModelAndView executeEndState(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.jdom.Element stateDef, WebFlowMementoStack mementos)
          Execute given end state.
protected  org.springframework.web.servlet.ModelAndView executeFlowState(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.jdom.Element stateDef, WebFlowMementoStack mementos)
          Execute given flow state.
protected  org.springframework.web.servlet.ModelAndView executeState(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.jdom.Element stateDef, WebFlowMementoStack mementos)
          Execute given state.
protected  org.springframework.web.servlet.ModelAndView executeState(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String state, WebFlowMementoStack mementos)
          Execute specified state.
protected  org.springframework.web.servlet.ModelAndView executeViewState(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.jdom.Element stateDef, WebFlowMementoStack mementos)
          Execute given view state.
protected  org.jdom.Element findStateDef(java.lang.String state)
          Find the state definition for specified state.
protected  org.jdom.Element findTransitionDef(org.jdom.Element stateDef, java.lang.String event)
          Find the transition definition linked with specified event in given state definition.
 org.springframework.context.ApplicationContext getApplicationContext()
           
 java.lang.String getName()
          Return the name of this web flow.
 org.springframework.core.io.Resource getWebFlowResource()
          Get the resource from which the web flow is loaded.
 void load()
          Load the web flow definition from the resource specified by the "webFlowResource" property.
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
           
 void setWebFlowResource(org.springframework.core.io.Resource webFlowResource)
          Set the resource from which the web flow is loaded.
 org.springframework.web.servlet.ModelAndView start(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, WebFlowMementoStack mementos)
          Start the web flow.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log
Constructor Detail

SimpleWebFlow

public SimpleWebFlow()
Method Detail

getWebFlowResource

public org.springframework.core.io.Resource getWebFlowResource()

Get the resource from which the web flow is loaded.


setWebFlowResource

public void setWebFlowResource(org.springframework.core.io.Resource webFlowResource)

Set the resource from which the web flow is loaded.


afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

load

public void load()
          throws WebFlowException

Load the web flow definition from the resource specified by the "webFlowResource" property.

Throws:
WebFlowException

getApplicationContext

public org.springframework.context.ApplicationContext getApplicationContext()

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Throws:
org.springframework.beans.BeansException

getName

public java.lang.String getName()

Return the name of this web flow. This is configured in the flow definition.


start

public org.springframework.web.servlet.ModelAndView start(javax.servlet.http.HttpServletRequest request,
                                                          javax.servlet.http.HttpServletResponse response,
                                                          WebFlowMementoStack mementos)
                                                   throws WebFlowException
Description copied from interface: WebFlow

Start the web flow.

Specified by:
start in interface WebFlow
Parameters:
request - current HTTP request
response - current HTTP response
mementos - flow call stack
Throws:
WebFlowException - in case of error

execute

public org.springframework.web.servlet.ModelAndView execute(javax.servlet.http.HttpServletRequest request,
                                                            javax.servlet.http.HttpServletResponse response,
                                                            java.lang.String state,
                                                            java.lang.String event,
                                                            WebFlowMementoStack mementos)
                                                     throws WebFlowException
Description copied from interface: WebFlow

Execute an event in a state of the web flow.

Specified by:
execute in interface WebFlow
Parameters:
request - current HTTP request
response - current HTTP response
state - state in which the event should be triggered
event - event that should be signaled
mementos - flow call stack
Throws:
WebFlowException - in case of error

findStateDef

protected org.jdom.Element findStateDef(java.lang.String state)

Find the state definition for specified state. Returns null if the state cannot be found.


findTransitionDef

protected org.jdom.Element findTransitionDef(org.jdom.Element stateDef,
                                             java.lang.String event)

Find the transition definition linked with specified event in given state definition. Returns null if there is no such transition.


executeState

protected org.springframework.web.servlet.ModelAndView executeState(javax.servlet.http.HttpServletRequest request,
                                                                    javax.servlet.http.HttpServletResponse response,
                                                                    java.lang.String state,
                                                                    WebFlowMementoStack mementos)
                                                             throws WebFlowException

Execute specified state.

Parameters:
request - current HTTP request
response - current HTTP response
state - the state to execute
mementos - flow call stack
Throws:
WebFlowException - in case of error

executeState

protected org.springframework.web.servlet.ModelAndView executeState(javax.servlet.http.HttpServletRequest request,
                                                                    javax.servlet.http.HttpServletResponse response,
                                                                    org.jdom.Element stateDef,
                                                                    WebFlowMementoStack mementos)
                                                             throws WebFlowException

Execute given state.

Parameters:
request - current HTTP request
response - current HTTP response
stateDef - definition of the state to execute
mementos - flow call stack
Throws:
WebFlowException - in case of error

executeViewState

protected org.springframework.web.servlet.ModelAndView executeViewState(javax.servlet.http.HttpServletRequest request,
                                                                        javax.servlet.http.HttpServletResponse response,
                                                                        org.jdom.Element stateDef,
                                                                        WebFlowMementoStack mementos)
                                                                 throws WebFlowException

Execute given view state. This will return the model and view to render.

Parameters:
request - current HTTP request
response - current HTTP response
stateDef - definition of the state to execute
mementos - flow call stack
Throws:
WebFlowException - in case of error

executeActionState

protected org.springframework.web.servlet.ModelAndView executeActionState(javax.servlet.http.HttpServletRequest request,
                                                                          javax.servlet.http.HttpServletResponse response,
                                                                          org.jdom.Element stateDef,
                                                                          WebFlowMementoStack mementos)
                                                                   throws WebFlowException

Execute given action state. This will execute all actions defined for the state untill a transition is triggered. Once that happens, a transition to the target state is done.

Parameters:
request - current HTTP request
response - current HTTP response
stateDef - definition of the state to execute
mementos - flow call stack
Throws:
WebFlowException - in case of error

executeFlowState

protected org.springframework.web.servlet.ModelAndView executeFlowState(javax.servlet.http.HttpServletRequest request,
                                                                        javax.servlet.http.HttpServletResponse response,
                                                                        org.jdom.Element stateDef,
                                                                        WebFlowMementoStack mementos)
                                                                 throws WebFlowException

Execute given flow state. This will load and execute a sub flow and do the necessary mapping to the sub flow model.

Parameters:
request - current HTTP request
response - current HTTP response
stateDef - definition of the state to execute
mementos - flow call stack
Throws:
WebFlowException - in case of error

executeEndState

protected org.springframework.web.servlet.ModelAndView executeEndState(javax.servlet.http.HttpServletRequest request,
                                                                       javax.servlet.http.HttpServletResponse response,
                                                                       org.jdom.Element stateDef,
                                                                       WebFlowMementoStack mementos)
                                                                throws WebFlowException

Execute given end state. This terminates the flow and does the necessary mapping to the parent flow if there is one.

Parameters:
request - current HTTP request
response - current HTTP response
stateDef - definition of the state to execute
mementos - flow call stack
Throws:
WebFlowException - in case of error

toString

public java.lang.String toString()