org.norther.tammi.spray.template.flow
Interface StepFlowContext

All Known Implementing Classes:
DefaultStepFlowContext, FlowTool

public interface StepFlowContext

An interface to contexts maintaing the state of flows and steps.

Implementations should guarantee that its state can be modified by only one thread at the time.

Author:
Ilkka Priha

Field Summary
static int CANCELLED_ACTION
          The cancelled action phase.
static int NO_ACTION
          The no action phase.
static int POST_ACTION
          The post-action phase.
static int PRE_ACTION
          The pre-action phase.
static int SUBMIT_ACTION
          The submit-action phase.
 
Method Summary
 Set attributeNameSet()
          Returns a set of context attribute names.
 void cancelSelection()
          Cancels the selection.
 void clearAttributes()
          Clears all context attributes.
 void clearSelection()
          Clears the selection.
 boolean containsAttribute(String name)
          Checks the named context attribute.
 void finishSelection(ServletRequest request, ServletResponse response, FilterChain chain)
          Finishes a new selection.
 int getActionPhase()
          Gets the action phase.
 Object getAttribute(String name)
          Gets the named context attribute.
 Object getAttribute(String name, Object defaultValue)
          Gets the named context attribute with a default value.
 FlowStep getFlow()
          Gets the current flow.
 FlowFilter getFlowFilter()
          Gets the flow filter of this context if available.
 Map getFormVariableIndeces(FlowStep step, ServletRequest request, ServletResponse response, FilterChain chain)
          Gets a map of flow step form variable indeces of the specified request.
 String getProperty(FlowStep step, String name)
          Gets the named property of the specified step.
 long getReservationTime()
          Gets the last reservation time.
 FlowStep getRoot()
          Gets the root flow.
 String getSelectedFlowName()
          Gets the selected flow name.
 int getSelectedStepIndex()
          Gets the index of the selected step.
 String getSelectedStepPath()
          Gets the selected step path.
 String getSelectedTemplatePath()
          Gets the selected template path.
 Variable getSelectedVariable()
          Gets the selected variable.
 FlowStep getStep()
          Gets the current step.
 TemplateContext getTemplateContext(ServletRequest request, ServletResponse response, FilterChain chain)
          Gets the template context of the specified request.
 String getTransition(FlowStep step, String state)
          Gets the named transition of the specified step.
 boolean isFlowEnabled(FlowStep flow)
          Checks whether the specified flow is enabled.
 boolean isNewSelection()
          Checks whether a new selection is set.
 boolean isReserved()
          Checks whether this context is reserved by some other thread than the current one.
 boolean isRestrictedRoutes()
          Checks whether step routes are restricted by a route matrix.
 boolean isRoot()
          Checks whether the current step is the root.
 boolean isState(FlowStep step, String state)
          Checks the named state of the specified step.
 boolean isStepEnabled(FlowStep step, FlowStep flow, int index)
          Checks whether the route from the specified step to the indexed one in the specified flow is enabled.
 boolean isValid()
          Checks whether this context is valid.
 FlowStep prepareSelection(ServletRequest request, ServletResponse response, FilterChain chain)
          Prepares a new selection.
 void release()
          Releases this context after state changes.
 void removeAttribute(String name)
          Removes the named context attribute.
 String removeProperty(FlowStep step, String name)
          Removes the named property of the specified step.
 String removeTransition(FlowStep step, String state)
          Removes the named transition of the specified step.
 void renewFormVariables(FlowStep step, ServletRequest request, ServletResponse response, FilterChain chain)
          Renews flow step form variables of the specified request.
 void reserve(long t)
          Reserves this context for state changes at the specified time unless obsolete or interrupted.
 void resetFormVariables(FlowStep step, ServletRequest request, ServletResponse response, FilterChain chain)
          Resets flow step form variables of the specified request.
 void setAttribute(String name, Object value)
          Sets the named context attribute.
 void setProperty(FlowStep step, String name, String value)
          Sets the named property of the specified step.
 void setSelectedFlowName(String name)
          Sets the selected flow name.
 void setSelectedStepIndex(int step)
          Sets the index of the selected step.
 void setSelectedStepPath(String path)
          Sets the selected step path.
 void setSelectedTemplatePath(String path)
          Sets the selected template path.
 void setSelectedVariable(Variable variable)
          Sets the selected variable.
 void setState(FlowStep step, String state, boolean flag)
          Sets the named state of the specified step.
 void setStepEnabled(FlowStep step, FlowStep flow, int index, boolean flag)
          Sets whether the route from the specified step to the indexed one is in the specified flow enabled.
 void setTransition(FlowStep step, String state, String value)
          Sets the named transition of the specified step.
 

Field Detail

NO_ACTION

static final int NO_ACTION
The no action phase.

See Also:
Constant Field Values

PRE_ACTION

static final int PRE_ACTION
The pre-action phase.

See Also:
Constant Field Values

POST_ACTION

static final int POST_ACTION
The post-action phase.

See Also:
Constant Field Values

SUBMIT_ACTION

static final int SUBMIT_ACTION
The submit-action phase.

See Also:
Constant Field Values

CANCELLED_ACTION

static final int CANCELLED_ACTION
The cancelled action phase.

See Also:
Constant Field Values
Method Detail

reserve

void reserve(long t)
             throws InterruptedException
Reserves this context for state changes at the specified time unless obsolete or interrupted.

Parameters:
t - the reservation time in msecs.
Throws:
InterruptedException - if obsolete or interrupted.

release

void release()
Releases this context after state changes.


isReserved

boolean isReserved()
Checks whether this context is reserved by some other thread than the current one.

Returns:
true if reserved, false otherwise.

getReservationTime

long getReservationTime()
Gets the last reservation time.

Returns:
the time in msecs.

isValid

boolean isValid()
Checks whether this context is valid.

Returns:
true if valid, false otherwise.

isRoot

boolean isRoot()
Checks whether the current step is the root.

Returns:
true if the root, false otherwise.

getRoot

FlowStep getRoot()
Gets the root flow.

Returns:
the root flow or null.

getFlow

FlowStep getFlow()
Gets the current flow.

Returns:
the current flow or null.

getStep

FlowStep getStep()
Gets the current step.

Returns:
the current step or null.

isRestrictedRoutes

boolean isRestrictedRoutes()
Checks whether step routes are restricted by a route matrix.

Returns:
true if restricted, false otherwise.

isFlowEnabled

boolean isFlowEnabled(FlowStep flow)
Checks whether the specified flow is enabled.

Parameters:
flow - the target flow.
Returns:
true if enabled, false otherwise.

isStepEnabled

boolean isStepEnabled(FlowStep step,
                      FlowStep flow,
                      int index)
Checks whether the route from the specified step to the indexed one in the specified flow is enabled.

Parameters:
step - the source step.
flow - the target flow.
index - the index of the target step.
Returns:
true if enabled, false otherwise.

setStepEnabled

void setStepEnabled(FlowStep step,
                    FlowStep flow,
                    int index,
                    boolean flag)
Sets whether the route from the specified step to the indexed one is in the specified flow enabled.

Parameters:
step - the source step.
flow - the target flow.
index - the index of the target step.
flag - true if enabled, false otherwise.

isState

boolean isState(FlowStep step,
                String state)
Checks the named state of the specified step.

Parameters:
step - the flow step.
state - the state name.
Returns:
true if set, false otherwise.

setState

void setState(FlowStep step,
              String state,
              boolean flag)
Sets the named state of the specified step.

Parameters:
step - the flow step.
state - the state name.
flag - true if set, false otherwise.

getProperty

String getProperty(FlowStep step,
                   String name)
Gets the named property of the specified step.

Parameters:
step - the flow step.
name - the property name.
Returns:
the value of the property.

setProperty

void setProperty(FlowStep step,
                 String name,
                 String value)
Sets the named property of the specified step.

Parameters:
step - the flow step.
name - the property name.
value - the value of the property.

removeProperty

String removeProperty(FlowStep step,
                      String name)
Removes the named property of the specified step.

Parameters:
step - the flow step.
name - the property name.
Returns:
the value of the property.

getTransition

String getTransition(FlowStep step,
                     String state)
Gets the named transition of the specified step.

Parameters:
step - the flow step.
state - the state name.
Returns:
the value of the transition or null.

setTransition

void setTransition(FlowStep step,
                   String state,
                   String value)
Sets the named transition of the specified step.

Parameters:
step - the flow step.
state - the state name.
value - the value of the transition.

removeTransition

String removeTransition(FlowStep step,
                        String state)
Removes the named transition of the specified step.

Parameters:
step - the flow step.
state - the state name.
Returns:
the value of the transition.

getActionPhase

int getActionPhase()
Gets the action phase.

Returns:
the action phase.

getAttribute

Object getAttribute(String name)
Gets the named context attribute.

Parameters:
name - the attribute name.
Returns:
the attribute value or null.

getAttribute

Object getAttribute(String name,
                    Object defaultValue)
Gets the named context attribute with a default value.

Parameters:
name - the attribute name.
defaultValue - the default value.
Returns:
the attribute value or null.

setAttribute

void setAttribute(String name,
                  Object value)
Sets the named context attribute.

Parameters:
name - the attribute name.
value - the attribute value.

containsAttribute

boolean containsAttribute(String name)
Checks the named context attribute.

Parameters:
name - the attribute name.
Returns:
true if defined, false othwerwise.

removeAttribute

void removeAttribute(String name)
Removes the named context attribute.

Parameters:
name - the attribute name.

clearAttributes

void clearAttributes()
Clears all context attributes.


attributeNameSet

Set attributeNameSet()
Returns a set of context attribute names.

Returns:
a read-only set of attribute names.

getSelectedStepPath

String getSelectedStepPath()
Gets the selected step path.

Returns:
the path of the selected step.

setSelectedStepPath

void setSelectedStepPath(String path)
Sets the selected step path.

Parameters:
path - the path of the selected step.

getSelectedFlowName

String getSelectedFlowName()
Gets the selected flow name.

Returns:
the name of the selected flow.

setSelectedFlowName

void setSelectedFlowName(String name)
Sets the selected flow name.

Note that the selected step index is set to the beginning of the flow.

Parameters:
name - the name of the selected flow.

getSelectedStepIndex

int getSelectedStepIndex()
Gets the index of the selected step.

Returns:
the index of selected step.

setSelectedStepIndex

void setSelectedStepIndex(int step)
Sets the index of the selected step.

Parameters:
step - the index of the selected step.

getSelectedTemplatePath

String getSelectedTemplatePath()
Gets the selected template path.

Returns:
the selected template path.

setSelectedTemplatePath

void setSelectedTemplatePath(String path)
Sets the selected template path.

Note that only one template can be passed through the selection, more complicated cases must be handled with other mechanisms.

Parameters:
path - the selected template path.

getSelectedVariable

Variable getSelectedVariable()
Gets the selected variable.

Returns:
the selected variable.

setSelectedVariable

void setSelectedVariable(Variable variable)
Sets the selected variable.

Note that only one variable can be passed through the selection, more complicated cases must be handled with other mechanisms.

Parameters:
variable - the selected variable.

isNewSelection

boolean isNewSelection()
Checks whether a new selection is set.

Returns:
true if set, false otherwise.

cancelSelection

void cancelSelection()
Cancels the selection.


clearSelection

void clearSelection()
Clears the selection.


prepareSelection

FlowStep prepareSelection(ServletRequest request,
                          ServletResponse response,
                          FilterChain chain)
                          throws AccessDeniedException,
                                 ExecutionException,
                                 InterruptedException
Prepares a new selection.

Parameters:
request - the servlet request.
response - the servlet response.
chain - the filter chain.
Returns:
the selected step or null.
Throws:
AccessDeniedException - for denied access.
ExecutionException - if activation failed.
InterruptedException - if activation was interrupted.

finishSelection

void finishSelection(ServletRequest request,
                     ServletResponse response,
                     FilterChain chain)
                     throws AccessDeniedException,
                            ExecutionException,
                            InterruptedException
Finishes a new selection.

Parameters:
request - the servlet request.
response - the servlet response.
chain - the filter chain.
Throws:
AccessDeniedException - for denied access.
ExecutionException - if activation failed.
InterruptedException - if activation was interrupted.

getTemplateContext

TemplateContext getTemplateContext(ServletRequest request,
                                   ServletResponse response,
                                   FilterChain chain)
                                   throws TemplateException
Gets the template context of the specified request.

Parameters:
request - the servlet request.
response - the servlet response.
chain - the filter chain.
Returns:
the template context.
Throws:
TemplateException - on errors.

getFormVariableIndeces

Map getFormVariableIndeces(FlowStep step,
                           ServletRequest request,
                           ServletResponse response,
                           FilterChain chain)
Gets a map of flow step form variable indeces of the specified request. The indeces are mapped by the corresponding form prefixes.

Parameters:
step - the flow step.
request - the servlet request.
response - the servlet response.
chain - the filter chain.
Returns:
the form variable index map.

resetFormVariables

void resetFormVariables(FlowStep step,
                        ServletRequest request,
                        ServletResponse response,
                        FilterChain chain)
Resets flow step form variables of the specified request.

Parameters:
step - the flow step.
request - the servlet request.
response - the servlet response.
chain - the filter chain.

renewFormVariables

void renewFormVariables(FlowStep step,
                        ServletRequest request,
                        ServletResponse response,
                        FilterChain chain)
                        throws ConstructionException
Renews flow step form variables of the specified request.

Parameters:
step - the flow step.
request - the servlet request.
response - the servlet response.
chain - the filter chain.
Throws:
ConstructionException - if construction fails.

getFlowFilter

FlowFilter getFlowFilter()
Gets the flow filter of this context if available.

Returns:
the flow filter or null.


Copyright © 2004 The Norther Organization. All rights reserved.