Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java?view=diff&r1=149228&r2=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
 Sun Jan 30 22:58:37 2005
@@ -24,13 +24,16 @@
 import org.apache.beehive.netui.pageflow.handler.ForwardRedirectHandler;
 import org.apache.beehive.netui.pageflow.handler.LoginHandler;
 import org.apache.beehive.netui.pageflow.handler.ReloadableClassHandler;
+import org.apache.beehive.netui.pageflow.handler.Handlers;
+import org.apache.beehive.netui.pageflow.handler.ActionForwardHandler;
+import org.apache.beehive.netui.pageflow.handler.FlowControllerHandlerContext;
 import org.apache.beehive.netui.pageflow.internal.AdapterManager;
-import org.apache.beehive.netui.pageflow.internal.ContextCache;
 import org.apache.beehive.netui.pageflow.internal.DefaultURLRewriter;
 import org.apache.beehive.netui.pageflow.internal.FlowControllerAction;
 import org.apache.beehive.netui.pageflow.internal.InternalUtils;
 import org.apache.beehive.netui.pageflow.internal.JavaControlUtils;
 import org.apache.beehive.netui.pageflow.internal.RequestValues;
+import org.apache.beehive.netui.pageflow.internal.LegacySettings;
 import org.apache.beehive.netui.pageflow.scoping.ScopedRequest;
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
 import org.apache.beehive.netui.pageflow.interceptor.Interceptor;
@@ -122,6 +125,8 @@
     private Map< String, Class > _formBeanClasses = new HashMap< String, Class 
>();
     private Map< String, List< ActionMapping > > _overloadedActions = new 
HashMap< String, List< ActionMapping > >();
     private ServletContainerAdapter _servletContainerAdapter;
+    private Handlers _handlers;
+    private LegacySettings _legacySettings;
     private ConcurrentHashMap< String, Class > _pageServletClasses = new 
ConcurrentHashMap< String, Class >();
     private PageFlowPageFilter _pageServletFilter;
     
@@ -188,8 +193,7 @@
         {
             try
             {
-                instance = ( ActionForm ) InternalUtils.newReloadableInstance(
-                        config.getType(), request, getServletContext() );
+                instance = ( ActionForm ) InternalUtils.newReloadableInstance( 
config.getType(), getServletContext() );
                 
                 if ( _log.isDebugEnabled() )
                 {
@@ -326,7 +330,7 @@
         ActionForm bean = super.processActionForm( request, response, mapping 
);
         if ( bean == null )
         {
-            bean = InternalUtils.createActionForm( request, mapping, 
moduleConfig, servlet, getServletContext() );
+            bean = InternalUtils.createActionForm( mapping, moduleConfig, 
servlet, getServletContext() );
         }
         
         return bean;
@@ -445,7 +449,8 @@
         //
         // Allow weblogic to do a security check on forwarded requests, if 
that feature is enabled.
         //
-        if ( ContextCache.get( servletContext ).shouldDoSecureForwards() && 
RequestValues.isForwardedRequest( request ) )
+        if ( LegacySettings.get( servletContext ).shouldDoSecureForwards()
+             && RequestValues.isForwardedRequest( request ) )
         {
             //
             // In some situations (namely, in scoped requests under portal), 
the initial weblogic
@@ -750,8 +755,7 @@
         // First reinitialize the reloadable class handler.  This will bounce 
a classloader if necessary.
         //
         ServletContext servletContext = getServletContext();
-        ContextCache contextCache = ContextCache.get( servletContext );
-        contextCache.getReloadableClassHandler().reinit( request );
+        _handlers.getReloadableClassHandler().reloadClasses( new 
RequestContext( request, response ) );
         
         //
         // Initialize the ServletContext in the request.  Often, we need 
access to the ServletContext when we only
@@ -992,6 +996,13 @@
         super.init( actionServlet, mc );
         
         //
+        // Cache a reference to the ServletContainerAdapter, the Handlers, and 
the LegacySettings.
+        //
+        _servletContainerAdapter = AdapterManager.getServletContainerAdapter( 
getServletContext() );
+        _legacySettings = LegacySettings.get( getServletContext() );
+        _handlers = Handlers.get( getServletContext() );
+        
+        //
         // Cache a list of overloaded actions for each overloaded action path 
(actions are overloaded by form bean type).
         //
         cacheOverloadedActionMappings();
@@ -1001,12 +1012,6 @@
         //
         cacheFormClasses();
         
-        //
-        // Cache a reference to the ServletContainerAdapter.
-        //
-        _servletContainerAdapter = AdapterManager.getServletContainerAdapter( 
getServletContext() );
-        
-        
         _pageServletFilter = new PageServletFilter();
     }
     
@@ -1055,7 +1060,7 @@
     private void cacheFormClasses()
     {
         FormBeanConfig[] formBeans = moduleConfig.findFormBeanConfigs();
-        ReloadableClassHandler rch = ContextCache.get( getServletContext() 
).getReloadableClassHandler();
+        ReloadableClassHandler rch = _handlers.getReloadableClassHandler();
         
         for ( int i = 0; i < formBeans.length; i++ )
         {
@@ -1255,7 +1260,7 @@
                 Map< String, SharedFlowController > sharedFlows = 
PageFlowUtils.getSharedFlows( request );
                 if ( sharedFlows == null ) return true;
                 if ( dot == actionPath.length() - 1 ) return true;     // 
empty action name
-                assert actionPath.startsWith( "/" ) : actionPath;
+                assert actionPath.length() > 0 && actionPath.charAt( 0 ) == 
'/' : actionPath;
                 String sharedFlowName = actionPath.substring( 1, dot );
                 SharedFlowController sf = sharedFlows.get( sharedFlowName );
                 
@@ -1359,9 +1364,12 @@
         }
 
         // Check the current user against the list of required roles
+        FlowController fc = RequestValues.getCurrentFlowController( request );
+        FlowControllerHandlerContext context = new 
FlowControllerHandlerContext( request, response, fc );
+        
         for ( int i = 0; i < roles.length; i++ )
         {
-            if ( ContextCache.get( getServletContext() 
).getLoginHandler().isUserInRole( roles[i], request ) )
+            if ( _handlers.getLoginHandler().isUserInRole( context, roles[i] ) 
)
             {
                 if ( _log.isDebugEnabled() )
                 {
@@ -1381,12 +1389,12 @@
         //
         // Here, Struts sends an HTTP error.  We try to let the current page 
flow handle a relevant exception.
         //
-        LoginHandler loginHandler = ContextCache.get( getServletContext() 
).getLoginHandler();
+        LoginHandler loginHandler = _handlers.getLoginHandler();
         String actionName = InternalUtils.getActionName( mapping );
         FlowController currentFC = RequestValues.getCurrentFlowController( 
request );
         PageFlowException ex;
         
-        if ( loginHandler.getUserPrincipal( request ) == null )
+        if ( loginHandler.getUserPrincipal( context ) == null )
         {
             ex = currentFC.createNotLoggedInException( actionName, request );
         }
@@ -1402,7 +1410,6 @@
         }
         else
         {
-            assert ex instanceof ResponseErrorCodeSender : 
ex.getClass().getName();
             ( ( ResponseErrorCodeSender ) ex ).sendResponseErrorCode( response 
);
         }
         
@@ -1433,7 +1440,9 @@
             throws IOException, ServletException
     {
         ServletContext servletContext = getServletContext();
-        ForwardRedirectHandler fwdRedirectHandler = ContextCache.get( 
servletContext ).getForwardRedirectHandler();
+        ForwardRedirectHandler fwdRedirectHandler = 
_handlers.getForwardRedirectHandler();
+        FlowController fc = RequestValues.getCurrentFlowController( request );
+        FlowControllerHandlerContext context = new 
FlowControllerHandlerContext( request, response, fc );
 
         //
         // The following is similar to what's in super.processForwardConfig(), 
but it avoids putting
@@ -1467,31 +1476,32 @@
                 ActionMapping mapping = ( ActionMapping ) 
request.getAttribute( Globals.MAPPING_KEY );
                 assert mapping != null;
                 ActionForm form = InternalUtils.getFormBean( mapping, request 
);
-                PageFlowController curJpf = PageFlowUtils.getCurrentPageFlow( 
request );
                 Forward pfFwd = new Forward( ( ActionForward ) fwd, 
servletContext );
-                fwd = ForwardHandler.processForward( pfFwd, mapping, request, 
response, form, servletContext, curJpf );
+                ActionForwardHandler handler = 
_handlers.getActionForwardHandler();
+                fwd = handler.doForward( context, pfFwd, mapping, 
InternalUtils.getActionName( mapping ), null, form );
             }
             
             String path = fwd.getPath();
+            boolean startsWithSlash = path.length() > 0 && path.charAt( 0 ) == 
'/';
             
             //
             // If the URI is absolute (e.g., starts with "http:"), do a 
redirect to it no matter what.
             //
             if ( FileUtils.isAbsoluteURI( path ) )
             {
-                fwdRedirectHandler.redirect( addScopeParams( path, request ), 
request, response );                
+                fwdRedirectHandler.redirect( context, addScopeParams( path, 
request ) );
             }
             else if ( fwd.getRedirect() )
             {
                 String redirectURI;
                 
-                if ( path.startsWith( "/" ) && fwd instanceof Forward && ( ( 
Forward ) fwd ).isExplicitPath() )
+                if ( startsWithSlash && fwd instanceof Forward && ( ( Forward 
) fwd ).isExplicitPath() )
                 {
                     redirectURI = path;
                 }
                 else if ( fwd instanceof Forward && ( ( Forward ) fwd 
).isExternalRedirect() )
                 {
-                    assert path.startsWith( "/" ) : path; // comipiler should 
ensure path starts with '/'
+                    assert startsWithSlash : path; // compiler should ensure 
path starts with '/'
                     redirectURI = path;
                 }
                 else
@@ -1499,13 +1509,13 @@
                     redirectURI = request.getContextPath() + 
RequestUtils.forwardURL( request, fwd );
                 }
                 
-                fwdRedirectHandler.redirect( addScopeParams( redirectURI, 
request ), request, response );
+                fwdRedirectHandler.redirect( context, addScopeParams( 
redirectURI, request ) );
             }
             else
             {
                 String fwdURI;
                 
-                if ( path.startsWith( "/" ) && fwd instanceof Forward && ( ( 
Forward ) fwd ).isExplicitPath() )
+                if ( startsWithSlash && fwd instanceof Forward && ( ( Forward 
) fwd ).isExplicitPath() )
                 {
                     fwdURI = path;
                 }
@@ -1532,8 +1542,8 @@
         }
     }
     
-    protected boolean changeScheme( String webappRelativeURI, String scheme, 
int port, HttpServletRequest request,
-                                 HttpServletResponse response )
+    protected boolean changeScheme( String webappRelativeURI, String scheme, 
int port, 
+                                    FlowControllerHandlerContext context )
         throws URISyntaxException, IOException, ServletException
     {
         if ( port == -1 )
@@ -1545,6 +1555,7 @@
                 return false;
             }
         }
+        
         //
         // First put all request attributes into the session, so they can be 
added to the
         // redirected request.
@@ -1552,6 +1563,8 @@
         Map attrs = new HashMap();
         String queryString = null;
         ServletContext servletContext = getServletContext();
+        assert context.getRequest() instanceof HttpServletRequest : "don't 
support ServletRequest currently.";
+        HttpServletRequest request = ( HttpServletRequest ) 
context.getRequest();
         
         for ( Enumeration e = request.getAttributeNames(); 
e.hasMoreElements(); )
         {
@@ -1576,8 +1589,8 @@
                                    request.getContextPath() + 
webappRelativeURI,
                                    queryString, null );
         
-        ForwardRedirectHandler fwdRedirectHandler = ContextCache.get( 
servletContext ).getForwardRedirectHandler();
-        fwdRedirectHandler.redirect( redirectURI.toString(), request, response 
);
+        ForwardRedirectHandler fwdRedirectHandler = 
_handlers.getForwardRedirectHandler();
+        fwdRedirectHandler.redirect( context, redirectURI.toString() );
         
         if ( _log.isDebugEnabled() )
         {
@@ -1588,11 +1601,11 @@
     }
     
     /**
-     * @deprecated Use [EMAIL PROTECTED] ContextCache#shouldDoSecureForwards} 
instead.
+     * @deprecated Use [EMAIL PROTECTED] 
LegacySettings#shouldDoSecureForwards} instead.
      */
     protected boolean shouldDoSecureForwards()
     {
-        return ContextCache.get( getServletContext() 
).shouldDoSecureForwards();
+        return _legacySettings.shouldDoSecureForwards();
     }
 
     protected void doForward( String uri, HttpServletRequest request, 
HttpServletResponse response )
@@ -1600,7 +1613,6 @@
     {
         boolean securityRedirected = false;
         ServletContext servletContext = getServletContext();
-        ContextCache contextCache = ContextCache.get( servletContext );
 
         //
         // As in the TilesRequestProcessor.doForward(), if the response has 
already been commited,
@@ -1608,11 +1620,14 @@
         //
         if ( response.isCommitted() )
         {
-            doInclude(uri, request, response);
+            doInclude( uri, request, response );
             return;
         }
+        
+        FlowController fc = RequestValues.getCurrentFlowController( request );
+        FlowControllerHandlerContext context = new 
FlowControllerHandlerContext( request, response, fc );
 
-        if ( contextCache.shouldDoSecureForwards() )
+        if ( _legacySettings.shouldDoSecureForwards() )
         {
             SecurityProtocol sp = PageFlowUtils.getSecurityProtocol( uri, 
servletContext, request );
             
@@ -1625,7 +1640,7 @@
                         if ( sp.equals( SecurityProtocol.UNSECURE ) )
                         {
                             int listenPort = 
_servletContainerAdapter.getListenPort( request );
-                            securityRedirected = changeScheme( uri, 
SCHEME_UNSECURE, listenPort, request, response );
+                            securityRedirected = changeScheme( uri, 
SCHEME_UNSECURE, listenPort, context );
                         }
                     }
                     else
@@ -1633,7 +1648,7 @@
                         if ( sp.equals( SecurityProtocol.SECURE ) )
                         {
                             int secureListenPort = 
_servletContainerAdapter.getSecureListenPort( request );
-                            securityRedirected = changeScheme( uri, 
SCHEME_SECURE, secureListenPort, request, response );
+                            securityRedirected = changeScheme( uri, 
SCHEME_SECURE, secureListenPort, context );
                         }
                     }
                 }
@@ -1648,8 +1663,8 @@
         {
             if ( ! processPageForward( uri, request, response ) )
             {
-                ForwardRedirectHandler fwdRedirectHandler = 
contextCache.getForwardRedirectHandler();
-                fwdRedirectHandler.forward( uri, request, response );
+                ForwardRedirectHandler fwdRedirectHandler = 
_handlers.getForwardRedirectHandler();
+                fwdRedirectHandler.forward( context, uri );
             }
         }
     }
@@ -1908,7 +1923,7 @@
         }
     }
     
-    void processActionForward( HttpServletRequest request, HttpServletResponse 
response, ActionForward forward )
+    void doActionForward( HttpServletRequest request, HttpServletResponse 
response, ActionForward forward )
         throws IOException, ServletException
     {
         processForwardConfig( request, response, forward );

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java?view=diff&r1=149228&r2=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
 Sun Jan 30 22:58:37 2005
@@ -794,7 +794,7 @@
     public static void addValidationError( String propertyName, String 
messageKey, Object[] messageArgs,
                                            ServletRequest request )
     {
-        InternalUtils.addActionMessage( propertyName, new ActionMessage( 
messageKey, messageArgs ), request );
+        InternalUtils.addActionError( propertyName, new ActionMessage( 
messageKey, messageArgs ), request );
     }
     
     
@@ -837,7 +837,7 @@
     public static void addActionMessage( ServletRequest request, String 
propertyName, String messageKey,
                                          Object ... messageArgs )
     {
-        InternalUtils.addActionMessage( propertyName, new ActionMessage( 
messageKey, messageArgs ), request );
+        InternalUtils.addActionError( propertyName, new ActionMessage( 
messageKey, messageArgs ), request );
     }
     
     /**
@@ -851,7 +851,7 @@
     public static void addActionMessageExpression( ServletRequest request, 
String propertyName, String expression,
                                                    Object ... messageArgs )
     {
-        InternalUtils.addActionMessage( propertyName, new ExpressionMessage( 
expression, messageArgs ), request );
+        InternalUtils.addActionError( propertyName, new ExpressionMessage( 
expression, messageArgs ), request );
     }
     
     /**
@@ -1119,21 +1119,21 @@
     }
     
     /**
-     * @deprecated This is an internal utility.  [EMAIL PROTECTED] 
InternalUtils#dumpRequest} can be used, but it is
+     * @deprecated This is an internal utility.  [EMAIL PROTECTED] 
ServletUtils#dumpRequest} can be used, but it is
      *             not guaranteed to be supported in the future.
      */ 
     public static void dumpRequest( HttpServletRequest request, PrintStream 
output )
     {
-        InternalUtils.dumpRequest( request, output );
+        ServletUtils.dumpRequest( request, output );
     }
     
     /**
-     * @deprecated This is an internal utility.  [EMAIL PROTECTED] 
InternalUtils#dumpServletContext} can be used, but it is
+     * @deprecated This is an internal utility.  [EMAIL PROTECTED] 
ServletUtils#dumpServletContext} can be used, but it is
      *             not guaranteed to be supported in the future.
      */ 
     public static void dumpServletContext( ServletContext context, PrintStream 
output )
     {
-        InternalUtils.dumpServletContext( context, output );
+        ServletUtils.dumpServletContext( context, output );
     }
     
     /**

Added: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/RequestContext.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/RequestContext.java?view=auto&rev=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/RequestContext.java
 (added)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/RequestContext.java
 Sun Jan 30 22:58:37 2005
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.pageflow;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+public class RequestContext
+{
+    private ServletRequest _request;
+    private ServletResponse _response;
+
+    public RequestContext( ServletRequest request, ServletResponse response )
+    {
+        _request = request;
+        _response = response;
+    }
+
+    public ServletRequest getRequest()
+    {
+        return _request;
+    }
+
+    public ServletResponse getResponse()
+    {
+        return _response;
+    }
+}

Propchange: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/RequestContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/SharedFlowController.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/SharedFlowController.java?view=diff&r1=149228&r2=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/SharedFlowController.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/SharedFlowController.java
 Sun Jan 30 22:58:37 2005
@@ -88,18 +88,23 @@
         return getClass().getName();
     }
     
-    PreviousPageInfo getPreviousPageInfoLegacy( PageFlowController curJpf, 
HttpServletRequest request )
+    /**
+     * Get a legacy PreviousPageInfo.
+     * @deprecated This method will be removed without replacement in a future 
release.
+     */ 
+    public PreviousPageInfo getPreviousPageInfoLegacy( PageFlowController 
curJpf, HttpServletRequest request )
     {
         assert curJpf != null;
         return curJpf.getCurrentPageInfo();        
     }
     
     /**
-     * Called from [EMAIL PROTECTED] FlowController#forwardTo}.
+     * Store information about recent pages displayed.  Usually should not be 
called directly.
+     * @exclude
      */ 
-    void savePreviousPageInfo( ActionForward forward, ActionForm form, 
ActionMapping mapping,
-                               HttpServletRequest request, ServletContext 
servletContext,
-                               boolean isSpecialForward )
+    public void savePreviousPageInfo( ActionForward forward, ActionForm form, 
ActionMapping mapping,
+                                      HttpServletRequest request, 
ServletContext servletContext,
+                                      boolean isSpecialForward )
     {
         //
         // Special case: if the given forward has a path to a page in the 
current pageflow,

Added: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ActionForwardHandler.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ActionForwardHandler.java?view=auto&rev=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ActionForwardHandler.java
 (added)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ActionForwardHandler.java
 Sun Jan 30 22:58:37 2005
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.pageflow.handler;
+
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.config.ModuleConfig;
+import org.apache.beehive.netui.pageflow.PreviousPageInfo;
+import org.apache.beehive.netui.pageflow.PageFlowController;
+import org.apache.beehive.netui.pageflow.Forward;
+import org.apache.beehive.netui.pageflow.PageFlowStack;
+import org.apache.beehive.netui.pageflow.interceptor.action.ActionInterceptor;
+
+public interface ActionForwardHandler
+        extends Handler
+{
+    ActionForward doForward( FlowControllerHandlerContext context, 
ActionForward fwd, ActionMapping mapping, 
+                             String actionName, ModuleConfig altModuleConfig, 
ActionForm form );
+
+    ActionForward doAutoViewRender( FlowControllerHandlerContext context, 
ActionMapping mapping, ActionForm form );
+
+    ActionForward doReturnToPage( FlowControllerHandlerContext context, 
PreviousPageInfo prevPageInfo,
+                                  PageFlowController currentPageFlow, 
ActionForm currentForm,
+                                  String actionName, Forward pageFlowFwd );
+
+    ActionForward doReturnToAction( FlowControllerHandlerContext context, 
String actionName, Forward pageFlowFwd );
+
+    ActionForward doNestingReturn( FlowControllerHandlerContext context, 
Forward pageFlowFwd, 
+                                   ActionMapping mapping, ActionForm form );
+
+    ActionForward handleInterceptorReturn( FlowControllerHandlerContext 
context, PageFlowController poppedPageFlow,
+                                           PageFlowStack.PushedPageFlow 
pushedPageFlowWrapper, String returnAction,
+                                           ActionMapping actionMapping, 
ActionForm form, ActionInterceptor interceptor );
+}

Propchange: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ActionForwardHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/BaseHandler.java
 (from r148858, 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultHandler.java)
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/BaseHandler.java?view=diff&rev=149229&p1=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultHandler.java&r1=148858&p2=incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/BaseHandler.java&r2=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultHandler.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/BaseHandler.java
 Sun Jan 30 22:58:37 2005
@@ -15,9 +15,7 @@
  *
  * $Header:$
  */
-package org.apache.beehive.netui.pageflow.internal;
-
-import org.apache.beehive.netui.pageflow.handler.Handler;
+package org.apache.beehive.netui.pageflow.handler;
 
 import javax.servlet.ServletContext;
 import java.io.Serializable;
@@ -26,26 +24,45 @@
 /**
  * Default implementation of the base Handler interface.  Simply stores a 
reference to the ServletContext.
  */
-public class DefaultHandler
+public abstract class BaseHandler
         implements Handler, Serializable
 {
     private transient ServletContext _servletContext;
+    private HandlerConfig _config;
+    private Handler _previousHandler;
     
+    protected BaseHandler()
+    {
+    }
     
     /**
      * Initialize.
      * 
+     * @param handlerConfig the configuration object for this Handler.
+     * @param previousHandler the previously-registered Handler, which this 
one can adapt.
      * @param servletContext the ServletContext for the webapp that is 
creating this object.
      */
-    public void init( ServletContext servletContext )
+    public void init( HandlerConfig handlerConfig, Handler previousHandler, 
ServletContext servletContext )
     {
         _servletContext = servletContext;
+        _previousHandler = previousHandler;
+        _config = handlerConfig;
     }
     
     protected final ServletContext getServletContext()
     {
         assert _servletContext != null;
         return _servletContext;
+    }
+    
+    protected Handler getPreviousHandler()
+    {
+        return _previousHandler;
+    }
+    
+    protected HandlerConfig getConfig()
+    {
+        return _config;
     }
 
     public void reinit( ServletContext servletContext )

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ExceptionsHandler.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ExceptionsHandler.java?view=diff&r1=149228&r2=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ExceptionsHandler.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ExceptionsHandler.java
 Sun Jan 30 22:58:37 2005
@@ -37,16 +37,13 @@
 public interface ExceptionsHandler
     extends Handler
 {
-    ActionForward handleException( Throwable ex, ActionMapping actionMapping, 
ActionForm form,
-                                   FlowController flowController, 
HttpServletRequest request,
-                                   HttpServletResponse response, 
ServletContext servletContext )
+    ActionForward handleException( FlowControllerHandlerContext context, 
Throwable ex, ActionMapping actionMapping,
+                                   ActionForm form )
         throws IOException, ServletException;
 
-    Throwable unwrapException( Throwable ex );
+    Throwable unwrapException( FlowControllerHandlerContext context, Throwable 
ex );
 
-    void exposeException( Throwable ex, ActionMapping actionMapping, 
HttpServletRequest request,
-                          HttpServletResponse response, ServletContext 
servletContext );
+    void exposeException( FlowControllerHandlerContext context, Throwable ex, 
ActionMapping actionMapping );
 
-    boolean eatUnhandledException( Throwable ex, HttpServletRequest request, 
HttpServletResponse response,
-                                   ServletContext servletContext );
+    boolean eatUnhandledException( FlowControllerHandlerContext context, 
Throwable ex );
 }

Added: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/FlowControllerHandlerContext.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/FlowControllerHandlerContext.java?view=auto&rev=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/FlowControllerHandlerContext.java
 (added)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/FlowControllerHandlerContext.java
 Sun Jan 30 22:58:37 2005
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.pageflow.handler;
+
+import org.apache.beehive.netui.pageflow.RequestContext;
+import org.apache.beehive.netui.pageflow.FlowController;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+public class FlowControllerHandlerContext
+        extends RequestContext
+{
+    private FlowController _flowController;
+    
+    public FlowControllerHandlerContext( ServletRequest request, 
ServletResponse response,
+                                         FlowController flowController )
+    {
+        super( request, response );
+        _flowController = flowController;
+    }
+
+    public FlowController getFlowController()
+    {
+        return _flowController;
+    }
+}

Propchange: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/FlowControllerHandlerContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ForwardRedirectHandler.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ForwardRedirectHandler.java?view=diff&r1=149228&r2=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ForwardRedirectHandler.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ForwardRedirectHandler.java
 Sun Jan 30 22:58:37 2005
@@ -17,8 +17,6 @@
  */
 package org.apache.beehive.netui.pageflow.handler;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import javax.servlet.ServletException;
 import java.io.IOException;
 
@@ -29,9 +27,9 @@
 public interface ForwardRedirectHandler
         extends Handler
 {
-    public void redirect( String uri, HttpServletRequest request, 
HttpServletResponse response )
+    public void redirect( FlowControllerHandlerContext context, String uri )
             throws IOException, ServletException;
 
-    public void forward( String uri, HttpServletRequest request, 
HttpServletResponse response )
+    public void forward( FlowControllerHandlerContext context, String uri )
             throws IOException, ServletException;
 }

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/Handler.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/Handler.java?view=diff&r1=149228&r2=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/Handler.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/Handler.java
 Sun Jan 30 22:58:37 2005
@@ -28,9 +28,11 @@
     /**
      * Initialize.
      * 
+     * @param handlerConfig the configuration object for this Handler.
+     * @param previousHandler the previously-registered Handler, which this 
one can adapt.
      * @param servletContext the ServletContext for the webapp that is 
creating this object.
      */
-    public void init( ServletContext servletContext );
+    public void init( HandlerConfig handlerConfig, Handler previousHandler, 
ServletContext servletContext );
     
     /**
      * Reinitialize, normally used to reconsitute transient data that was lost 
during serialization.

Added: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/HandlerConfig.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/HandlerConfig.java?view=auto&rev=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/HandlerConfig.java
 (added)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/HandlerConfig.java
 Sun Jan 30 22:58:37 2005
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.pageflow.handler;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.io.Serializable;
+
+public class HandlerConfig
+        implements Serializable
+{
+    private Map< String, String > _customProperties = new HashMap< String, 
String >();
+    private String _handlerClass;
+
+    public HandlerConfig( String handlerClass )
+    {
+        _handlerClass = handlerClass;
+    }
+    
+    public Map< String, String > getCustomProperties()
+    {
+        return _customProperties;
+    }
+    
+    void addCustomProperty( String name, String value )
+    {
+        _customProperties.put( name, value );
+    }
+    
+    public String getCustomProperty( String name )
+    {
+        return _customProperties.get( name );
+    }
+
+    public String getHandlerClass()
+    {
+        return _handlerClass;
+    }
+}

Propchange: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/HandlerConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/Handlers.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/Handlers.java?view=auto&rev=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/Handlers.java
 (added)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/Handlers.java
 Sun Jan 30 22:58:37 2005
@@ -0,0 +1,238 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.pageflow.handler;
+
+import org.apache.beehive.netui.util.DiscoveryUtils;
+import org.apache.beehive.netui.util.config.bean.CustomProperty;
+import org.apache.beehive.netui.util.config.bean.NetuiConfigDocument;
+import org.apache.beehive.netui.util.config.bean.PageflowHandlers;
+import org.apache.beehive.netui.util.config.ConfigUtil;
+import org.apache.beehive.netui.util.logging.Logger;
+import org.apache.beehive.netui.pageflow.internal.InternalConstants;
+import org.apache.beehive.netui.pageflow.internal.DefaultLoginHandler;
+import 
org.apache.beehive.netui.pageflow.internal.DefaultForwardRedirectHandler;
+import 
org.apache.beehive.netui.pageflow.internal.DefaultReloadableClassHandler;
+import org.apache.beehive.netui.pageflow.internal.DefaultExceptionsHandler;
+import org.apache.beehive.netui.pageflow.internal.DefaultActionForwardHandler;
+import org.apache.beehive.netui.pageflow.internal.DefaultHandler;
+import org.apache.beehive.netui.pageflow.PageFlowActionServlet;
+import org.apache.beehive.netui.pageflow.PageFlowContextListener;
+
+import javax.servlet.ServletContext;
+import java.io.Serializable;
+
+public class Handlers
+        implements Serializable
+{
+    private static final Logger _log = Logger.getInstance( Handlers.class );
+    
+    private static final String CONTEXT_ATTR = InternalConstants.ATTR_PREFIX + 
"_handlers";
+    
+    private ActionForwardHandler _actionForwardHandler = null;
+    private ExceptionsHandler _exceptionsHandler = null;
+    private ForwardRedirectHandler _forwardRedirectHandler = null;
+    private LoginHandler _loginHandler = null;
+    private ReloadableClassHandler _reloadableClassHandler = null;
+    private transient ServletContext _servletContext;
+    
+    public static Handlers get( ServletContext servletContext )
+    {
+        Handlers handlers = ( Handlers ) servletContext.getAttribute( 
CONTEXT_ATTR );
+        
+        if ( handlers == null )
+        {
+            if ( _log.isErrorEnabled() )
+            {
+                _log.error( "Page Flow Handlers not initialized; either "
+                            + PageFlowActionServlet.class.getName() + " must 
be the Struts action servlet, or "
+                            + PageFlowContextListener.class.getName() + " must 
be registered as a listener in web.xml." );
+            }
+            
+            //
+            // We can initialize it now, but it's not good because many 
requests could conceivably be in this
+            // code at the same time.
+            //
+            return init( servletContext );
+        }
+        
+        handlers.reinit( servletContext );       
+        return handlers;
+    }
+    
+    public static Handlers init( ServletContext servletContext )
+    {
+        assert servletContext.getAttribute( CONTEXT_ATTR ) == null : 
Handlers.class.getName() + " already initialized.";
+        Handlers handlers = new Handlers( servletContext );
+        servletContext.setAttribute( CONTEXT_ATTR, handlers );
+        return handlers;
+    }
+    
+    private Handlers( ServletContext servletContext )
+    {
+        _servletContext = servletContext;
+        
+        //
+        // Load/create Handlers.
+        //
+        NetuiConfigDocument.NetuiConfig netuiConfig = ConfigUtil.getConfig();
+        PageflowHandlers handlers = netuiConfig.getPageflowHandlers();
+        
+        DefaultHandler defaultActionForwardHandler = new 
DefaultActionForwardHandler( servletContext );
+        DefaultHandler defaultExceptionsHandler = new 
DefaultExceptionsHandler( servletContext );
+        DefaultHandler defaultForwardRedirectHandler = new 
DefaultForwardRedirectHandler( servletContext );
+        DefaultHandler defaultLoginHandler = new DefaultLoginHandler( 
servletContext );
+        DefaultHandler defaultReloadableClassHandler = new 
DefaultReloadableClassHandler( servletContext );
+        
+        if ( handlers != null )
+        {
+            _actionForwardHandler = ( ActionForwardHandler )
+                    adaptHandler( handlers.getActionForwardHandlerArray(), 
defaultActionForwardHandler,
+                                  ActionForwardHandler.class, servletContext );
+            
+            _exceptionsHandler = ( ExceptionsHandler )
+                    adaptHandler( handlers.getExceptionsHandlerArray(), 
defaultExceptionsHandler,
+                                  ExceptionsHandler.class, servletContext );
+            
+            _forwardRedirectHandler = ( ForwardRedirectHandler )
+                    adaptHandler( handlers.getForwardRedirectHandlerArray(), 
defaultForwardRedirectHandler,
+                                  ForwardRedirectHandler.class, servletContext 
);
+            
+            _loginHandler = ( LoginHandler )
+                    adaptHandler( handlers.getLoginHandlerArray(), 
defaultLoginHandler, LoginHandler.class,
+                                  servletContext );
+            
+            _reloadableClassHandler = ( ReloadableClassHandler )
+                    adaptHandler( handlers.getReloadableClassHandlerArray(), 
defaultReloadableClassHandler,
+                                  ReloadableClassHandler.class, servletContext 
);
+        }
+    }
+    
+    public void reinit( ServletContext servletContext )
+    {
+        if ( _servletContext == null )
+        {
+            _servletContext = servletContext;
+            _actionForwardHandler.reinit( servletContext );
+            _exceptionsHandler.reinit( servletContext );
+            _forwardRedirectHandler.reinit( servletContext );
+            _loginHandler.reinit( servletContext );
+            _reloadableClassHandler.reinit( servletContext );
+        }
+    }
+
+    public ActionForwardHandler getActionForwardHandler()
+    {
+        return _actionForwardHandler;
+    }
+
+    public ExceptionsHandler getExceptionsHandler()
+    {
+        return _exceptionsHandler;
+    }
+    
+    public ForwardRedirectHandler getForwardRedirectHandler()
+    {
+        return _forwardRedirectHandler;
+    }
+    
+    public LoginHandler getLoginHandler()
+    {
+        return _loginHandler;
+    }
+    
+    public ReloadableClassHandler getReloadableClassHandler()
+    {
+        return _reloadableClassHandler;
+    }
+    
+    private static Handler adaptHandler( 
org.apache.beehive.netui.util.config.bean.Handler[] handlerBeanConfigs, 
+                                         DefaultHandler defaultHandler, Class 
baseClassOrInterface,
+                                         ServletContext servletContext )
+    {
+        Handler retVal = defaultHandler;
+        
+        for ( int i = 0; i < handlerBeanConfigs.length; i++ )
+        {
+            String handlerClass = handlerBeanConfigs[i].getHandlerClass();
+            CustomProperty[] props = 
handlerBeanConfigs[i].getCustomPropertyArray();
+            Handler handler = createHandler( handlerClass, 
baseClassOrInterface, retVal, servletContext );
+            
+            if ( handler != null )
+            {
+                HandlerConfig config = new HandlerConfig( handlerClass );
+                
+                for ( int j = 0; j < props.length; j++ )
+                {
+                    CustomProperty prop = props[j];
+                    config.addCustomProperty( prop.getName(), prop.getValue() 
);
+                }
+                
+                handler.init( config, retVal, servletContext );
+                retVal = handler;
+            }
+        }
+        
+        defaultHandler.setRegisteredHandler( retVal );
+        return retVal;
+    }
+    
+    /**
+     * Instantiates a handler, based on the class name in the given 
HandlerConfig.
+     * 
+     * @param className the class name of the desired Handler.
+     * @param baseClassOrInterface the required base class or interface.  May 
be <code>null</code>.
+     * @return an initialized Handler.
+     */ 
+    private static Handler createHandler( String className, Class 
baseClassOrInterface, Handler previousHandler,
+                                         ServletContext servletContext )
+    {
+        assert Handler.class.isAssignableFrom( baseClassOrInterface )
+                : baseClassOrInterface.getName() + " cannot be assigned to " + 
Handler.class.getName();
+        
+        ClassLoader cl = DiscoveryUtils.getClassLoader();
+        
+        try
+        {
+            Class handlerClass = cl.loadClass( className );
+            
+            if ( ! baseClassOrInterface.isAssignableFrom( handlerClass ) )
+            {
+                _log.error( "Handler " + handlerClass.getName() + " does not 
implement or extend "
+                            + baseClassOrInterface.getName() );
+                return null;
+            }
+            
+            Handler handler = ( Handler ) handlerClass.newInstance();
+            return handler;
+        }
+        catch ( ClassNotFoundException e )
+        {
+            _log.error( "Could not find Handler class " + className, e );
+        }
+        catch ( InstantiationException e )
+        {
+            _log.error( "Could not instantiate Handler class " + className, e 
);
+        }
+        catch ( IllegalAccessException e )
+        {
+            _log.error( "Could not instantiate Handler class " + className, e 
);
+        }
+        
+        return null;
+    }
+}

Propchange: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/Handlers.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/LoginHandler.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/LoginHandler.java?view=diff&r1=149228&r2=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/LoginHandler.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/LoginHandler.java
 Sun Jan 30 22:58:37 2005
@@ -17,8 +17,6 @@
  */
 package org.apache.beehive.netui.pageflow.handler;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import javax.security.auth.login.LoginException;
 import java.security.Principal;
 
@@ -34,10 +32,9 @@
      * 
      * @param username the user to log in.
      * @param password the user's password.
-     * @param request the current HttpServletRequest.
      * @throws LoginException if the login fails.
      */ 
-    public void login( String username, String password, HttpServletRequest 
request, HttpServletResponse response )
+    public void login( FlowControllerHandlerContext context, String username, 
String password )
         throws LoginException;
     
     /**
@@ -45,24 +42,21 @@
      * 
      * @param invalidateSessions if <code>true</code>, current sessions 
associated with the current
      *            logged-in user will be invalidated.
-     * @param request the current HttpServletRequest.
      */ 
-    public void logout( boolean invalidateSessions, HttpServletRequest 
request, HttpServletResponse response );
+    public void logout( FlowControllerHandlerContext context, boolean 
invalidateSessions );
                         
     
     /**
      * Tell whether the current user is in a given role.
      * 
      * @param roleName the role to check.
-     * @param request the current HttpServletRequest.
      * @return <code>true</code> if the current logged-in user is in the given 
role.
      */ 
-    public boolean isUserInRole( String roleName, HttpServletRequest request );
+    public boolean isUserInRole( FlowControllerHandlerContext context, String 
roleName );
     
     /**
      * Get the current user.
-     * @param request the current HttpServletRequest.
      * @return a [EMAIL PROTECTED] Principal} that represents the current 
logged-in user.
      */ 
-    public Principal getUserPrincipal( HttpServletRequest request );
+    public Principal getUserPrincipal( FlowControllerHandlerContext context );
 }

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ReloadableClassHandler.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ReloadableClassHandler.java?view=diff&r1=149228&r2=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ReloadableClassHandler.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/handler/ReloadableClassHandler.java
 Sun Jan 30 22:58:37 2005
@@ -17,7 +17,7 @@
  */
 package org.apache.beehive.netui.pageflow.handler;
 
-import javax.servlet.http.HttpServletRequest;
+import org.apache.beehive.netui.pageflow.RequestContext;
 
 
 /**
@@ -34,7 +34,7 @@
 
     Class loadCachedClass( String className );
     
-    void reinit( HttpServletRequest request );
+    void reloadClasses( RequestContext context );
 
     ClassLoader getClassLoader();
 

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/interceptor/Interceptors.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/interceptor/Interceptors.java?view=diff&r1=149228&r2=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/interceptor/Interceptors.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/interceptor/Interceptors.java
 Sun Jan 30 22:58:37 2005
@@ -52,6 +52,9 @@
      */ 
     public static Interceptor createInterceptor( InterceptorConfig config, 
Class baseClassOrInterface )
     {
+        assert Interceptor.class.isAssignableFrom( baseClassOrInterface )
+                : baseClassOrInterface.getName() + " cannot be assigned to " + 
Interceptor.class.getName();
+        
         ClassLoader cl = DiscoveryUtils.getClassLoader();
         String className = config.getInterceptorClass();
         
@@ -59,7 +62,7 @@
         {
             Class interceptorClass = cl.loadClass( className );
             
-            if ( baseClassOrInterface != null && ! 
baseClassOrInterface.isAssignableFrom( interceptorClass ) )
+            if ( ! baseClassOrInterface.isAssignableFrom( interceptorClass ) )
             {
                 _log.error( "Interceptor " + interceptorClass.getName() + " 
does not implement or extend "
                             + baseClassOrInterface.getName() );
@@ -72,7 +75,7 @@
         }
         catch ( ClassNotFoundException e )
         {
-            _log.error( "Could not find interceptor class " + className );
+            _log.error( "Could not find interceptor class " + className, e );
         }
         catch ( InstantiationException e )
         {
@@ -81,10 +84,6 @@
         catch ( IllegalAccessException e )
         {
             _log.error( "Could not instantiate interceptor class " + 
className, e );
-        }
-        catch ( ClassCastException e )
-        {
-            _log.error( "Interceptor class " + className + " does not 
implement " + Interceptor.class.getName() );
         }
         
         return null;

Modified: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/AnyBeanActionForm.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/AnyBeanActionForm.java?view=diff&r1=149228&r2=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/AnyBeanActionForm.java
 (original)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/AnyBeanActionForm.java
 Sun Jan 30 22:58:37 2005
@@ -19,8 +19,8 @@
 
 import org.apache.beehive.netui.pageflow.FormData;
 import org.apache.beehive.netui.pageflow.Validatable;
-import org.apache.beehive.netui.pageflow.PageFlowUtils;
 import org.apache.beehive.netui.pageflow.handler.ReloadableClassHandler;
+import org.apache.beehive.netui.pageflow.handler.Handlers;
 import org.apache.beehive.netui.pageflow.config.PageFlowActionMapping;
 import org.apache.beehive.netui.util.logging.Logger;
 import org.apache.struts.action.ActionMapping;
@@ -67,7 +67,7 @@
             try
             {
                 ReloadableClassHandler reloadableHandler =
-                        ContextCache.get( getServlet().getServletContext() 
).getReloadableClassHandler();
+                        Handlers.get( getServlet().getServletContext() 
).getReloadableClassHandler();
                 _bean = reloadableHandler.newInstance( formClass );
             }
             catch ( Exception e )

Added: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultActionForwardHandler.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultActionForwardHandler.java?view=auto&rev=149229
==============================================================================
--- 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultActionForwardHandler.java
 (added)
+++ 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultActionForwardHandler.java
 Sun Jan 30 22:58:37 2005
@@ -0,0 +1,609 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.pageflow.internal;
+
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.config.ModuleConfig;
+
+import org.apache.beehive.netui.pageflow.interceptor.action.ActionInterceptor;
+import 
org.apache.beehive.netui.pageflow.interceptor.action.AfterNestedInterceptContext;
+import org.apache.beehive.netui.pageflow.interceptor.action.InterceptorForward;
+import org.apache.beehive.netui.pageflow.interceptor.InterceptorException;
+import org.apache.beehive.netui.pageflow.*;
+import org.apache.beehive.netui.pageflow.handler.FlowControllerHandlerContext;
+import org.apache.beehive.netui.pageflow.handler.ActionForwardHandler;
+import org.apache.beehive.netui.pageflow.handler.Handlers;
+import org.apache.beehive.netui.util.logging.Logger;
+import org.apache.beehive.netui.script.common.ImplicitObjectUtil;
+
+import static 
org.apache.beehive.netui.pageflow.PageFlowConstants.AUTO_VIEW_RENDER_FORWARD_NAME;
+import static 
org.apache.beehive.netui.pageflow.PageFlowConstants.ACTION_EXTENSION;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
+
+public class DefaultActionForwardHandler 
+        extends DefaultHandler
+        implements ActionForwardHandler
+{
+    private static final Logger _log = Logger.getInstance( 
DefaultActionForwardHandler.class );
+
+    public DefaultActionForwardHandler( ServletContext servletContext )
+    {
+        init( null, null, servletContext );
+    }
+
+    /**
+     * Perform any necessary updates to the request and user session 
(including updates to the
+     * PageFlowController stack), based on the given ActionForward.
+     * 
+     * @param context the current FlowControllerHandlerContext.
+     * @param fwd the Struts ActionForward that determines the next URI to be 
displayed.
+     * @param mapping the Struts ActionMapping for the current action being 
processed.
+     * @param actionName the name of the Struts action being processed.
+     * @param altModuleConfig an alternate module config (e.g., Global.app's 
ModuleConfig) from which to
+     *            resolve a forward if it can't be resolved from the given 
ActionMapping.
+     * @return the ActionForward object to pass to Struts for actual Servlet 
forwarding.
+     */  
+    public ActionForward doForward( FlowControllerHandlerContext context, 
ActionForward fwd, ActionMapping mapping, 
+                                    String actionName, ModuleConfig 
altModuleConfig, ActionForm form )
+    {
+        boolean isSpecialForward = false;
+        boolean isReturnToCurrentPage = false;
+        assert context.getRequest() instanceof HttpServletRequest : "don't 
support ServletRequest currently.";
+        HttpServletRequest request = ( HttpServletRequest ) 
context.getRequest();
+        FlowController flowController = context.getFlowController();
+        
+        //
+        // There is a special forward ("auto"), which signals us to render 
using a registered ViewRenderer.
+        // This is used as part of popup window support.
+        //
+        if ( fwd != null && AUTO_VIEW_RENDER_FORWARD_NAME.equals( 
fwd.getName() ) )
+        {
+            return getRegisteredHandler().doAutoViewRender( context, mapping, 
form );
+        }
+        
+        if ( fwd != null && fwd instanceof Forward )
+        {
+            Forward pageFlowFwd = ( Forward ) fwd;
+
+            pageFlowFwd.initialize( mapping, flowController, request );
+            pageFlowFwd.setAlternateModuleConfig( altModuleConfig );
+
+            if ( ! pageFlowFwd.doesResolve() )
+            {
+                PageFlowException ex =
+                        new UnresolvableForwardException( 
pageFlowFwd.getName(), actionName, flowController );
+                InternalUtils.throwPageFlowException( ex, request );
+            }
+
+            //
+            // If it's a return-to-page, do what's necessary to return to the 
previous page,
+            // with its state intact.
+            //
+            if ( pageFlowFwd.isReturnToPage() )
+            {
+                isSpecialForward = true;
+                
+                //
+                // We need access to _previousPageInfo from the *current 
PageFlow*.  That is
+                // most likely this FlowController, but if it's Global.app, 
then we don't want
+                // to use that.
+                //
+                PageFlowController curJpf = PageFlowUtils.getCurrentPageFlow( 
request );
+                
+                if ( curJpf == null )
+                {
+                    PageFlowException ex = new NoCurrentPageFlowException( 
actionName, pageFlowFwd );
+                    InternalUtils.throwPageFlowException( ex, request );
+                    assert false;   // throwPageFlowException() must throw.
+                }
+                
+                PreviousPageInfo prevPageInfo;
+                
+                switch ( pageFlowFwd.getReturnToType() )
+                {
+                    case Forward.RETURN_TO_CURRENT_PAGE:
+                        prevPageInfo = curJpf.getCurrentPageInfo();
+                        isReturnToCurrentPage = true;
+                        break;
+                        
+                    case Forward.RETURN_TO_PREVIOUS_PAGE:
+                        prevPageInfo = curJpf.getPreviousPageInfo();
+                        break;
+                    
+                    case Forward.RETURN_TO_PAGE:
+                        prevPageInfo = 
flowController.getPreviousPageInfoLegacy( curJpf, request );
+                        break;
+                    
+                    default:
+                        assert false : pageFlowFwd.getReturnToType();
+                        prevPageInfo = curJpf.getCurrentPageInfo();
+                }
+                
+                fwd =
+                  getRegisteredHandler().doReturnToPage( context, 
prevPageInfo, curJpf, form, actionName, pageFlowFwd );
+                
+                if ( prevPageInfo != null )
+                {
+                    mapping = prevPageInfo.getMapping();
+                    if ( form == null ) form = prevPageInfo.getForm();
+                }
+                
+                if ( _log.isDebugEnabled() )
+                {
+                    _log.debug( "return-to-page: " + ( fwd != null ? 
fwd.getPath() : "[null]" ) );
+                }
+            }
+            else if ( pageFlowFwd.isReturnToAction() )
+            {
+                isSpecialForward = true;
+                fwd = getRegisteredHandler().doReturnToAction( context, 
actionName, pageFlowFwd );
+            }
+            
+            //
+            // See if we should pop the current PageFlowController (done 
nesting).
+            //
+            if ( pageFlowFwd.isNestedReturn() )
+            {
+                isSpecialForward = true;
+                fwd = getRegisteredHandler().doNestingReturn( context, 
pageFlowFwd, mapping, form );
+            }
+
+            //
+            // Set ActionForms specified in the Forward.  Note that this 
overwrites any forms restored
+            // during return-to="page".
+            //
+            PageFlowUtils.setOutputForms( mapping, pageFlowFwd, request );
+            InternalUtils.addActionOutputs( pageFlowFwd.getActionOutputs() , 
request, true );
+        }
+
+        if ( fwd != null )
+        {
+            if ( _log.isDebugEnabled() )
+            {
+                if ( fwd.getRedirect() )
+                {
+                    _log.debug( "Redirecting to " + fwd.getPath() );
+                }
+                else
+                {
+                    _log.debug( "Forwarding to " + fwd.getPath() );
+                }
+            }
+        }
+        else
+        {
+            _log.debug( "null ActionForward -- not doing any forward or 
redirect." );
+        }
+        
+        //
+        // Save info on this forward for return-to="currentPage" or 
return-to="previousPage".  But, don't save
+        // the info if the current forward is a return-to="currentPage" -- we 
don't want this to turn into
+        // the page that's seen for *both* return-to="currentPage" and 
return-to="previousPage".
+        //
+        if ( ! isReturnToCurrentPage )
+        {
+            flowController.savePreviousPageInfo( fwd, form, mapping, request, 
getServletContext(), isSpecialForward );
+        }
+        
+        return fwd;
+    }
+    
+    public ActionForward doAutoViewRender( FlowControllerHandlerContext 
context, ActionMapping mapping, ActionForm form )
+    {
+        assert context.getRequest() instanceof HttpServletRequest : "don't 
support ServletRequest currently.";
+        assert context.getResponse() instanceof HttpServletResponse : "don't 
support ServletResponse currently.";
+        HttpServletRequest request = ( HttpServletRequest ) 
context.getRequest();
+        HttpServletResponse response = ( HttpServletResponse ) 
context.getResponse();
+        ViewRenderer vr = RequestValues.getViewRenderer( request );
+        
+        if ( vr != null )
+        {
+            _log.debug( "null ActionForward -- delegating to ViewRenderer " + 
vr + " to handle response." );
+            
+            try
+            {
+                vr.renderView( request, response, getServletContext() );
+            }
+            catch ( Throwable th )
+            {
+                try
+                {
+                    return context.getFlowController().handleException( th, 
mapping, form, request, response );
+                }
+                catch ( Exception e )
+                {
+                    _log.error( "Exception thrown while handling exception in 
ViewRenderer " + vr + ": "
+                                + e.getMessage(), th );
+                }
+            }
+            
+        }
+        else
+        {
+            _log.error( "Auto-render forward " + AUTO_VIEW_RENDER_FORWARD_NAME 
+ " used, but no ViewRenderer "
+                        + "was registered -- not doing any forward or 
redirect." );
+        }
+        
+        return null;
+    }
+    
+    /**
+     * Get an ActionForward to the original page that was visible before the 
previous action.
+     */
+    public ActionForward doReturnToPage( FlowControllerHandlerContext context, 
PreviousPageInfo prevPageInfo,
+                                         PageFlowController currentPageFlow, 
ActionForm currentForm,
+                                         String actionName, Forward 
pageFlowFwd )
+    {
+        assert context.getRequest() instanceof HttpServletRequest : "don't 
support ServletRequest currently.";
+        HttpServletRequest request = ( HttpServletRequest ) 
context.getRequest();
+        
+        if ( prevPageInfo == null )
+        {
+            if ( _log.isInfoEnabled() )
+            {
+                _log.info( "Attempted return-to-page, but previous page info 
was missing." );
+            }
+        
+            PageFlowException ex = new NoPreviousPageException( actionName, 
pageFlowFwd, currentPageFlow );
+            InternalUtils.throwPageFlowException( ex, request );
+        }
+        
+        //
+        // Figure out what URI to return to, and set the original form in the 
request or session.
+        //        
+        ActionForward retFwd = prevPageInfo.getForward();
+        ActionMapping prevMapping = prevPageInfo.getMapping();
+        
+        //
+        // Restore any forms that are specified by this Forward (overwrite the 
original forms).
+        //
+        if ( retFwd instanceof Forward )
+        {
+            PageFlowUtils.setOutputForms( prevMapping, ( Forward ) retFwd, 
request, false );
+            InternalUtils.addActionOutputs( ( ( Forward ) retFwd 
).getActionOutputs(), request, false );
+        }
+        
+        //
+        // If the user hit the previous page directly (without going through 
an action), prevMapping will be null.
+        //
+        if ( prevMapping != null )
+        {
+            //
+            // If the currently-posted form is of the right type, initialize 
the page with that (but we don't overwrite
+            // the form that was set above).
+            //
+            if ( currentForm != null ) PageFlowUtils.setOutputForm( 
prevMapping, currentForm, request, false );
+        
+            //
+            // Initialize the page with the original form it got forwarded 
(but we don't overwrite the form that was
+            // set above).
+            //
+            InternalUtils.setFormInScope( prevMapping.getName(), 
prevPageInfo.getForm(), prevMapping, request, false );
+        }
+            
+        //
+        // If we're forwarding to a page in a different pageflow, we need to 
make sure the returned ActionForward has
+        // the right module path, and that it has contextRelative=true.
+        //
+        FlowController flowController = context.getFlowController();
+        
+        if ( ! retFwd.getContextRelative() && flowController != 
currentPageFlow )
+        {
+
+            retFwd = new ActionForward( retFwd.getName(),
+                                        currentPageFlow.getModulePath() + 
retFwd.getPath(),
+                                        retFwd.getRedirect(),
+                                        true );
+
+        }
+        
+        if ( _log.isDebugEnabled() )
+        {
+            _log.debug( "Return-to-page in PageFlowController " + 
flowController.getClass().getName()
+                       + ": original URI " + retFwd.getPath() );
+        }
+        
+        if ( retFwd != null )
+        {
+            //
+            // If the new (return-to) Forward specifies a redirect value 
explicitly, use that; otherwise
+            // use the redirect value from the original Forward.
+            //
+            if ( pageFlowFwd.hasExplicitRedirectValue() ) retFwd.setRedirect( 
pageFlowFwd.getRedirect() );
+            
+            //
+            // If there's a query string, override the previous query string.
+            //
+            String fwdPath = retFwd.getPath();
+            String newQueryString = pageFlowFwd.getQueryString();
+            
+            if ( newQueryString != null )
+            {
+                int existingQuery = fwdPath.indexOf( '?' );
+                
+                if ( existingQuery != -1 )
+                {
+                    retFwd.setPath( fwdPath.substring( 0, existingQuery ) + 
newQueryString );
+                }
+                else
+                {
+                    retFwd.setPath( fwdPath + newQueryString );
+                }
+            }
+        }
+        
+        RequestValues.setPreviousPageInfo( request, prevPageInfo );
+        return retFwd;
+    }
+    
+    public ActionForward doReturnToAction( FlowControllerHandlerContext 
context, String actionName, Forward pageFlowFwd )
+    {
+        assert context.getRequest() instanceof HttpServletRequest : "don't 
support ServletRequest currently.";
+        HttpServletRequest request = ( HttpServletRequest ) 
context.getRequest();
+        
+        //
+        // We need access to _previousPageInfo from the *current PageFlow*.  
That is
+        // most likely this FlowController, but if it's Global.app, then we 
don't want
+        // to use that.
+        //
+        PageFlowController curJpf = PageFlowUtils.getCurrentPageFlow( request 
);
+        
+        if ( curJpf == null )
+        {
+            PageFlowException ex = new NoCurrentPageFlowException( actionName, 
pageFlowFwd );
+            InternalUtils.throwPageFlowException( ex, request );
+            assert false;   // throwPageFlowException() must throw.
+        }
+                        
+        PreviousActionInfo prevActionInfo = curJpf.getPreviousActionInfo();
+        
+        if ( prevActionInfo != null )
+        {
+            String actionURI = prevActionInfo.getActionURI();
+            
+            if ( _log.isDebugEnabled() )
+            {
+                _log.debug( "return-to-action: " + actionURI );
+            }
+
+            //
+            // If there's no form specified in this return-to-action forward, 
then use the original form that was saved
+            // in the action.  Only do this if we're not doing a redirect, 
which precludes request attributes.
+            //
+            if ( ! pageFlowFwd.isRedirect() && prevActionInfo.getForm() != null
+                 && pageFlowFwd.getFirstOutputForm( request ) == null )
+            {
+                pageFlowFwd.addOutputForm( prevActionInfo.getForm() );
+            }
+            
+            String query = pageFlowFwd.getQueryString();
+            if ( query == null )
+            {
+                query = "";
+            }
+            
+            //
+            // If the restoreQueryString attribute was set, use the query 
string from the original action URI.
+            //
+            boolean restoreQueryString = pageFlowFwd.doesRestoreQueryString();
+            if ( restoreQueryString )
+            {
+                String prevQuery = prevActionInfo.getQueryString();
+                
+                if ( prevQuery != null )
+                {
+                    query += ( query.length() > 0 ? "&" : "?" ) + prevQuery;
+                }
+            }
+
+            ActionForward fwd = new ActionForward( actionURI + query, 
pageFlowFwd.getRedirect() );
+            fwd.setContextRelative( true );
+            return fwd;
+        }
+        else
+        {
+            if ( _log.isInfoEnabled() )
+            {
+                _log.info( "Attempted return-to-action, but previous action 
info was missing." );
+            }
+            
+            PageFlowException ex = new NoPreviousActionException( actionName, 
pageFlowFwd, curJpf );
+            InternalUtils.throwPageFlowException( ex, request );
+            assert false;   // previous method always throws
+            return null;
+        }
+    }
+    
+    public ActionForward doNestingReturn( FlowControllerHandlerContext 
context, Forward pageFlowFwd, 
+                                          ActionMapping mapping, ActionForm 
form )
+    {
+        assert context.getRequest() instanceof HttpServletRequest : "don't 
support ServletRequest currently.";
+        assert context.getResponse() instanceof HttpServletResponse : "don't 
support ServletResponse currently.";
+        HttpServletRequest request = ( HttpServletRequest ) 
context.getRequest();
+        HttpServletResponse response = ( HttpServletResponse ) 
context.getResponse();
+        
+        PageFlowStack pfStack = PageFlowStack.get( request );
+        String returnAction = pageFlowFwd.getPath();
+                
+        if ( pfStack.isEmpty() )
+        {
+            PageFlowController curJpf = PageFlowUtils.getCurrentPageFlow( 
request );
+                    
+            if ( _log.isInfoEnabled() )
+            {
+                _log.info( "Tried to pop from empty PageFlow stack.  Current = 
"
+                           + curJpf.getClass().getName() );
+            }
+                    
+            if ( _log.isWarnEnabled() )
+            {
+                StringBuilder msg = new StringBuilder( "Tried to pop from 
empty PageFlow stack." );
+                msg.append( "  Current page flow is " );
+                msg.append( curJpf != null ? curJpf.getClass().getName() : 
null );
+                _log.warn( msg.append( '.' ).toString() );
+            }
+                    
+            PageFlowException ex = new EmptyNestingStackException( 
returnAction, curJpf );
+            InternalUtils.throwPageFlowException( ex, request );
+        }
+                
+        // Only nested PageFlowControllers can have return actions.
+        assert context.getFlowController() instanceof PageFlowController
+                : context.getFlowController().getClass().getName() + " is not 
a " + PageFlowController.class.getName();
+        ActionForward exceptionFwd = 
+                ( ( PageFlowController ) context.getFlowController() 
).exitNesting( request, response, mapping, form );
+        if ( exceptionFwd != null ) return exceptionFwd;
+                
+        PageFlowStack.PushedPageFlow pushedPageFlowWrapper = pfStack.pop( 
request );
+        PageFlowController poppedPageFlow = 
pushedPageFlowWrapper.getPageFlow();
+
+        if ( _log.isDebugEnabled() )
+        {
+            _log.debug( "Popped PageFlowController " + poppedPageFlow + " from 
the nesting stack" );
+        }
+
+        InternalUtils.setCurrentPageFlow( poppedPageFlow, request );
+
+                
+        //
+        // If an ActionInterceptor forwarded to the nested page flow, give it 
a chance to change the URI as the nested
+        // flow is returning.  If it doesn't, we'll go to the 
originally-intended Forward.
+        //
+        ActionInterceptor interceptor = pushedPageFlowWrapper.getInterceptor();
+                
+        if ( interceptor != null )
+        {
+            return getRegisteredHandler().handleInterceptorReturn( context, 
poppedPageFlow, pushedPageFlowWrapper,
+                                                                   
returnAction, mapping, form, interceptor );
+        }
+
+        //
+        // Raise the returned action on the popped pageflow.
+        //                    
+        assert returnAction.charAt( 0 ) != '/' : returnAction;
+
+        if ( _log.isDebugEnabled() )
+        {
+            _log.debug( "Action on popped PageFlowController is " + 
returnAction );
+        }
+
+        StringBuilder returnActionPath = new StringBuilder( 
poppedPageFlow.getModulePath() );
+        returnActionPath.append( '/' ).append( returnAction ).append( 
ACTION_EXTENSION );
+
+        //
+        // Store the returned form in the request.
+        //
+        ActionForm retForm = pageFlowFwd.getFirstOutputForm( request );
+        if ( retForm != null )
+        {
+            RequestValues.setForwardedFormBean( request, retForm );
+            ImplicitObjectUtil.loadOutputFormBean( request, 
InternalUtils.unwrapFormBean( retForm ) );
+        }
+                
+        // TODO: delete this deprecated feature (following line).  This is the 
Jpf.NavigateTo.page value.
+        request.setAttribute( InternalConstants.RETURNING_FROM_NESTING_ATTR, 
Boolean.TRUE );
+        
+        //
+        // Forward to the return-action on the nesting page flow.
+        //
+        ActionForward fwd = new ActionForward( returnActionPath.toString(), 
false );
+        fwd.setContextRelative( true );
+        return fwd;
+    }
+    
+    public ActionForward handleInterceptorReturn( FlowControllerHandlerContext 
context,
+                                                  PageFlowController 
poppedPageFlow,
+                                                  PageFlowStack.PushedPageFlow 
pushedPageFlowWrapper,
+                                                  String returnAction, 
ActionMapping actionMapping,
+                                                  ActionForm form, 
ActionInterceptor interceptor )
+    {
+        assert context.getRequest() instanceof HttpServletRequest : "don't 
support ServletRequest currently.";
+        assert context.getResponse() instanceof HttpServletResponse : "don't 
support ServletResponse currently.";
+        HttpServletRequest request = ( HttpServletRequest ) 
context.getRequest();
+        HttpServletResponse response = ( HttpServletResponse ) 
context.getResponse();
+        
+        RequestValues.setReturningFromActionIntercept( request, true );
+        
+        try
+        {
+            AfterNestedInterceptContext interceptorContext =
+                    new AfterNestedInterceptContext( request, response, 
getServletContext(), poppedPageFlow,
+                                                     
pushedPageFlowWrapper.getInterceptedForward(),
+                                                     
pushedPageFlowWrapper.getInterceptedActionName(),
+                                                     returnAction );
+            
+            interceptor.afterNestedIntercept( interceptorContext );
+            
+            if ( interceptorContext.hasInterceptorForward() )
+            {
+                InterceptorForward fwd = 
interceptorContext.getInterceptorForward();
+                
+                if ( _log.isDebugEnabled() )
+                {
+                    StringBuilder message = new StringBuilder();
+                    message.append( "Interceptor " );
+                    message.append( interceptor.getClass().getName() );
+                    message.append( " after nested page flow: " );
+                    
+                    if ( fwd != null )
+                    {
+                        message.append( "forwarding to " );
+                        message.append( fwd.getPath() );
+                    }
+                    else
+                    {
+                        message.append( "returned InterceptorForward is null." 
);
+                    }
+                    
+                    _log.debug( message.toString() );
+                }
+                
+                if ( fwd != null ) fwd.rehydrateRequest( request );
+                return fwd;
+            }
+        }
+        catch ( InterceptorException e )
+        {
+            _log.error( "Exception in " + interceptor.getClass().getName() + 
".afterNestedIntercept", e );
+            
+            try
+            {
+                return poppedPageFlow.handleException( e, actionMapping, form, 
request, response );
+            }
+            catch ( Exception anotherException )
+            {
+                _log.error( "Exception thrown while handling exception.", 
anotherException );
+            }
+        }
+        
+        //
+        // The interceptor declined to forward us anywhere -- just go to the 
originally-intended Forward.
+        //
+        return pushedPageFlowWrapper.getInterceptedForward();
+    }
+    
+    public ActionForwardHandler getRegisteredHandler()
+    {
+        return ( ActionForwardHandler ) super.getRegisteredHandler();
+    }
+}

Propchange: 
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DefaultActionForwardHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to