net.sourceforge.stripes.controller
Class ExecutionContext

java.lang.Object
  extended by net.sourceforge.stripes.controller.ExecutionContext

public class ExecutionContext
extends Object

Holds the execution context for processing a single request. The ExecutionContext is made available to Interceptor classes that are interleaved with the regular request processing lifecycle.

The ExecutionContext is not populated all at once, but in pieces as the request progresses. Check the accessor method for each item for information on when that item becomes available in the request processing lifecycle.

Since:
Stripes 1.3
Author:
Tim Fennell

Constructor Summary
ExecutionContext()
           
 
Method Summary
 ActionBean getActionBean()
          Retrieves the ActionBean instance that is associated with the current request.
 ActionBeanContext getActionBeanContext()
          Retrieves the ActionBeanContext associated with the current request.
 Method getHandler()
          Retrieves the handler Method that is targeted by the current request.
 LifecycleStage getLifecycleStage()
          Gets the current LifecycleStage being processed.
 Resolution getResolution()
          Gets the Resolution that will be executed at the end of the execution.
 boolean isResolutionFromHandler()
           
 Resolution proceed()
          Continues the flow of execution.
 void setActionBean(ActionBean actionBean)
          Sets the ActionBean associated with the current request.
 void setActionBeanContext(ActionBeanContext actionBeanContext)
          Sets the ActionBeanContext for the current request.
 void setHandler(Method handler)
          Sets the handler method that will be invoked to process the current request.
 void setInterceptors(Collection<Interceptor> stack)
          Used by the DispatcherServlet to initialize and/or swap out the list of Interceptor instances which should wrap the current LifecycleStage.
 void setLifecycleStage(LifecycleStage lifecycleStage)
          Sets the current stage in the request processing lifecycle.
 void setResolution(Resolution resolution)
          Sets the Resolution that will be executed to terminate this execution.
 void setResolutionFromHandler(boolean resolutionFromHandler)
           
 Resolution wrap(Interceptor target)
          Used by the DispatcherServlet to wrap a block of lifecycle code in Interceptor calls.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecutionContext

public ExecutionContext()
Method Detail

setInterceptors

public void setInterceptors(Collection<Interceptor> stack)
Used by the DispatcherServlet to initialize and/or swap out the list of Interceptor instances which should wrap the current LifecycleStage.

Parameters:
stack - a non-null (though possibly empty) ordered collection of interceptors

wrap

public Resolution wrap(Interceptor target)
                throws Exception
Used by the DispatcherServlet to wrap a block of lifecycle code in Interceptor calls.

Parameters:
target - a block of lifecycle/request processing code that is contained inside a class that implements Interceptor
Returns:
a Resolution instance or null depending on what is returned by the lifecycle code and any interceptors which intercept the execution
Throws:
Exception - if the lifecycle code or an interceptor throws an Exception

getActionBeanContext

public ActionBeanContext getActionBeanContext()
Retrieves the ActionBeanContext associated with the current request. Available to all interceptors regardless of LifecycleStage.

Returns:
the current ActionBeanContext

setActionBeanContext

public void setActionBeanContext(ActionBeanContext actionBeanContext)
Sets the ActionBeanContext for the current request.


getActionBean

public ActionBean getActionBean()
Retrieves the ActionBean instance that is associated with the current request. Available to interceptors only after LifecycleStage.ActionBeanResolution has occurred.

Returns:
the current ActionBean instance, or null if not yet resolved

setActionBean

public void setActionBean(ActionBean actionBean)
Sets the ActionBean associated with the current request.


getHandler

public Method getHandler()
Retrieves the handler Method that is targeted by the current request. Available to interceptors only after LifecycleStage.HandlerResolution has occurred.

Returns:
the current ActionBean instance, or null if not yet resolved

setHandler

public void setHandler(Method handler)
Sets the handler method that will be invoked to process the current request.


getResolution

public Resolution getResolution()
Gets the Resolution that will be executed at the end of the execution. This value is generally not populated until just prior to LifecycleStage.ResolutionExecution.

Returns:
the Resolution associated with this execution

setResolution

public void setResolution(Resolution resolution)
Sets the Resolution that will be executed to terminate this execution.


getLifecycleStage

public LifecycleStage getLifecycleStage()
Gets the current LifecycleStage being processed. This is always set to the appropriate lifecycle stage before invoking any interceptors or lifecycle code, so that interceptors that intercept at multiple lifecycle stages can be aware of which stage is being intercepted.

Returns:
the LifecycleStage currently being processed/intercepted

setLifecycleStage

public void setLifecycleStage(LifecycleStage lifecycleStage)
Sets the current stage in the request processing lifecycle.


proceed

public Resolution proceed()
                   throws Exception
Continues the flow of execution. If there are more interceptors in the stack intercepting the current lifecycle stage then the flow continues by calling the next interceptor. If there are no more interceptors then the lifecycle code is invoked.

Returns:
a Resolution if the lifecycle code or one of the interceptors returns one
Throws:
Exception - if the lifecycle code or one of the interceptors throws one

isResolutionFromHandler

public boolean isResolutionFromHandler()

setResolutionFromHandler

public void setResolutionFromHandler(boolean resolutionFromHandler)


? Copyright 2005-2006, Stripes Development Team.