protected Forward processActionPerform()

in ti/phase2/jars/core/src/java/org/apache/ti/pageflow/xwork/PageFlowAction.java [468:544]


    protected Forward processActionPerform()
            throws IOException, PageFlowException {
        PageFlowActionContext actionContext = PageFlowActionContext.get();
        String actionName = actionContext.getName();
        ActionInterceptorContext context = null;
        List/*< Interceptor >*/ interceptors = null;

        FlowController fc = actionContext.getFlowController();

        if (fc instanceof PageFlowController) {
            PageFlowController pfc = (PageFlowController) fc;
            context = new ActionInterceptorContext(pfc, null, actionName);
            interceptors = context.getActionInterceptors();
        }

        if (interceptors != null && interceptors.size() == 0) interceptors = null;

        try {
            //
            // Run any before-action interceptors.
            //
            if (interceptors != null && !actionContext.isReturningFromActionIntercept()) {
                Interceptors.doPreIntercept(context, interceptors);

                if (context.hasInterceptorForward()) {
                    InterceptorForward fwd = context.getInterceptorForward();

                    if (_log.isDebugEnabled()) {

                        Interceptor overridingInterceptor = context.getOverridingInterceptor();
                        StringBuffer msg = new StringBuffer();
                        msg.append("action interceptor ");
                        msg.append(overridingInterceptor.getClass().getName());
                        msg.append(" before action ");
                        msg.append(actionName);
                        msg.append(": forwarding to ");
                        msg.append(fwd != null ? fwd.getPath() : "null [no forward]");
                        _log.debug(msg.toString());
                    }

                    return fwd;
                }
            } else {
                actionContext.setReturningFromActionIntercept(false);
            }
            
            //
            // Execute the action.
            //
            ActionRunner actionExecutor = new ActionRunner();
            Forward ret = ActionInterceptors.wrapAction(context, interceptors, actionExecutor);
            
            //
            // Run any after-action interceptors.
            //
            if (interceptors != null) {
                context.setOriginalForward(ret);
                Interceptors.doPostIntercept(context, interceptors);

                if (context.hasInterceptorForward()) {
                    InterceptorForward fwd = context.getInterceptorForward();

                    if (_log.isDebugEnabled()) {
                        _log.debug("action interceptor " + context.getOverridingInterceptor().getClass().getName()
                                + " after action " + actionName + ": forwarding to "
                                + fwd != null ? fwd.getPath() : "null [no forward]");
                    }

                    return fwd;
                }
            }

            return ret;
        } catch (InterceptorException e) {
            throw new PageFlowException(e);
        }
    }