org.apache.beehive.netui.pageflow.interceptor.action
Class ActionInterceptor

Object
  extended by AbstractInterceptor
      extended by ActionInterceptor
All Implemented Interfaces:
Serializable, Interceptor

public abstract class ActionInterceptor
extends AbstractInterceptor

Base class for Page Flow action interceptors. These are configured in /WEB-INF/beehive-netui-config.xml like this:

    <netui-config xmlns="http://beehive.apache.org/netui/2004/server/config">
        ...
    
        <pageflow-action-interceptors>
            <global>
                <before-action>
                    <action-interceptor>
                        <interceptor-class>test.BeforeActionInterceptor1</interceptor-class>
                    </action-interceptor>
                    <action-interceptor>
                        <interceptor-class>test.BeforeActionInterceptor2</interceptor-class>
                    </action-interceptor>
                    ...
                </before-action>
                <after-action>
                    <action-interceptor>
                        <interceptor-class>test.AfterActionInterceptor1</interceptor-class>
                    </action-interceptor>
                    <action-interceptor>
                        <interceptor-class>test.AfterActionInterceptor2</interceptor-class>
                    </action-interceptor>
                </after-action>
            </global>
        </pageflow-action-interceptors>
 
        ...
    </netui-config>

 
Note that a registered ActionInterceptor is created and cached as a single instance per ServletContext. It should not hold any per-request or per-session state.

See Also:
Serialized Form

Constructor Summary
ActionInterceptor()
           
 
Method Summary
abstract  void afterNestedIntercept(AfterNestedInterceptContext context)
          Callback invoked after a nested page flow has been "injected" by preAction(org.apache.beehive.netui.pageflow.interceptor.action.ActionInterceptorContext, org.apache.beehive.netui.pageflow.interceptor.InterceptorChain), and before the original action has run.
abstract  void postAction(ActionInterceptorContext context, InterceptorChain chain)
          Callback invoked after the action is processed.
 void postInvoke(InterceptorContext context, InterceptorChain chain)
          Callback invoked after the action is processed.
abstract  void preAction(ActionInterceptorContext context, InterceptorChain chain)
          Callback invoked before the action is processed.
 void preInvoke(InterceptorContext context, InterceptorChain chain)
          Callback invoked before the action is processed.
protected  void setOverrideForward(InterceptorForward forward, ActionInterceptorContext context)
          Override the Forward, either before or after the target action is run.
 Object wrapAction(ActionInterceptorContext context, InterceptorChain chain)
          Optional method that "wraps" the target action invocation.
 
Methods inherited from class AbstractInterceptor
getConfig, init
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionInterceptor

public ActionInterceptor()
Method Detail

preAction

public abstract void preAction(ActionInterceptorContext context,
                               InterceptorChain chain)
                        throws InterceptorException
Callback invoked before the action is processed. During this method, setOverrideForward(org.apache.beehive.netui.pageflow.interceptor.action.InterceptorForward, org.apache.beehive.netui.pageflow.interceptor.action.ActionInterceptorContext) may be called to: InterceptorChain.continueChain() is called to invoke the rest of the interceptor chain, anywhere within this method (e.g., at the end, or within a try/finally).

Parameters:
context - the current ActionInterceptorContext.
chain - the interceptor chain. Calling continueChain on this runs the rest of the interceptors.
Throws:
InterceptorException

preInvoke

public void preInvoke(InterceptorContext context,
                      InterceptorChain chain)
               throws InterceptorException
Callback invoked before the action is processed. preAction(org.apache.beehive.netui.pageflow.interceptor.action.ActionInterceptorContext, org.apache.beehive.netui.pageflow.interceptor.InterceptorChain) may be used instead.

Parameters:
context - the interception context
chain - the chain of interceptors
Throws:
InterceptorException - an exception thrown when an error occurs during interception

postAction

public abstract void postAction(ActionInterceptorContext context,
                                InterceptorChain chain)
                         throws InterceptorException
Callback invoked after the action is processed. During this method, setOverrideForward(org.apache.beehive.netui.pageflow.interceptor.action.InterceptorForward, org.apache.beehive.netui.pageflow.interceptor.action.ActionInterceptorContext) may be called to: InterceptorChain.continueChain() is called to invoke the rest of the interceptor chain, anywhere within this method (e.g., at the end, or within a try/finally).

Parameters:
context - the current ActionInterceptorContext.
chain - the interceptor chain. Calling continueChain on this runs the rest of the interceptors.
Throws:
InterceptorException

postInvoke

public void postInvoke(InterceptorContext context,
                       InterceptorChain chain)
                throws InterceptorException
Callback invoked after the action is processed. postAction(org.apache.beehive.netui.pageflow.interceptor.action.ActionInterceptorContext, org.apache.beehive.netui.pageflow.interceptor.InterceptorChain) may be used instead.

Parameters:
context - the interceptor context
chain - the chain of interceptors
Throws:
InterceptorException - an exception thrown when an error occurs during interception

afterNestedIntercept

public abstract void afterNestedIntercept(AfterNestedInterceptContext context)
                                   throws InterceptorException
Callback invoked after a nested page flow has been "injected" by preAction(org.apache.beehive.netui.pageflow.interceptor.action.ActionInterceptorContext, org.apache.beehive.netui.pageflow.interceptor.InterceptorChain), and before the original action has run. During this method, setOverrideForward(org.apache.beehive.netui.pageflow.interceptor.action.InterceptorForward, org.apache.beehive.netui.pageflow.interceptor.action.ActionInterceptorContext) may be called to: InterceptorChain.continueChain() is called to invoke the rest of the interceptor chain, anywhere within this method (e.g., at the end, or within a try/finally).

Parameters:
context - an extension of ActionInterceptorContext which contains the return action from the injected nested page flow.
Throws:
InterceptorException

setOverrideForward

protected void setOverrideForward(InterceptorForward forward,
                                  ActionInterceptorContext context)
Override the Forward, either before or after the target action is run. See preAction(org.apache.beehive.netui.pageflow.interceptor.action.ActionInterceptorContext, org.apache.beehive.netui.pageflow.interceptor.InterceptorChain) and postAction(org.apache.beehive.netui.pageflow.interceptor.action.ActionInterceptorContext, org.apache.beehive.netui.pageflow.interceptor.InterceptorChain) for information on how this is used.

Parameters:
forward - an InterceptorForward that will override the target action's forward; or null to cancel navigation.
context - the current ActionInterceptorContext.

wrapAction

public Object wrapAction(ActionInterceptorContext context,
                         InterceptorChain chain)
                  throws InterceptorException
Optional method that "wraps" the target action invocation. This is mainly useful for surrounding an action (and the rest of the interceptor chain) with try/catch/finally. This default implementation simply returns continueChain on the passed-in InterceptorChain, which allows the rest of the interceptors and the action to run.

Parameters:
context - the current ActionInterceptorContext.
chain - the interceptor chain. This chain is different from the ones passed to preAction(org.apache.beehive.netui.pageflow.interceptor.action.ActionInterceptorContext, org.apache.beehive.netui.pageflow.interceptor.InterceptorChain) and postAction(org.apache.beehive.netui.pageflow.interceptor.action.ActionInterceptorContext, org.apache.beehive.netui.pageflow.interceptor.InterceptorChain) in that the action invocation itself is included in it.
Returns:
the ActionForward returned by the action.
Throws:
InterceptorException