Action action, ActionForm form, ActionMapping mapping )
throws IOException, ServletException
{
ServletContext servletContext = getServletContext();
String actionName = InternalUtils.getActionName( mapping );
ActionInterceptorContext context = null;
List/*< Interceptor >*/ interceptors = null;
if ( action instanceof FlowControllerAction )
{
FlowController fc = ( ( FlowControllerAction ) action ).getFlowController();
if ( fc instanceof PageFlowController )
{
PageFlowController pfc = ( PageFlowController ) fc;
context = new ActionInterceptorContext( request, response, servletContext, pfc, null, actionName );
interceptors = context.getActionInterceptors();
}
}
if ( interceptors != null && interceptors.size() == 0 ) interceptors = null;
try
{
//
// Run any before-action interceptors.
//
if ( interceptors != null && ! PageFlowRequestWrapper.get( request ).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
{
PageFlowRequestWrapper.get( request ).setReturningFromActionIntercept( false );
}
//
// Execute the action.
//
RequestInterceptorContext requestContext =
context != null ?
context :
new RequestInterceptorContext( request, response, getServletContext() );
ActionRunner actionExecutor = new ActionRunner( requestContext, action, form, mapping );
ActionForward 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;