You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2006/04/07 06:27:03 UTC

svn commit: r392179 - in /beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow: ./ internal/

Author: ekoneil
Date: Thu Apr  6 21:26:58 2006
New Revision: 392179

URL: http://svn.apache.org/viewcvs?rev=392179&view=rev
Log:
Add some Javadoc to core Page Flow classes.

BB: self
Test: NetUI pass


Modified:
    beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java
    beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java
    beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java
    beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowManagedObject.java
    beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
    beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DeferredSessionStorageHandler.java
    beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java

Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java?rev=392179&r1=392178&r2=392179&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowController.java Thu Apr  6 21:26:58 2006
@@ -874,6 +874,11 @@
                 readonly = pfam.isReadonly();
             }
 
+            /*
+            A read only Flow Controller is one that is marked as such via metadata.  If a FlowController
+            is read only, no steps need to be taken to ensure that it fails over into the session for
+            serialization in a cluster.
+             */
             if ( ! readonly )
             {
                 ensureFailover( getRequest() );

Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java?rev=392179&r1=392178&r2=392179&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/FlowControllerFactory.java Thu Apr  6 21:26:58 2006
@@ -358,13 +358,21 @@
             else
             {
                 //
-                // We're actually using the newly-created page flow, so call create() on it (*after* persisting
-                // in the session so the previous page flow's onDestroy() gets called before the new one's
-                // onCreate()).
+                // We're actually using the newly-created page flow, so take several steps that:
+                // 1. reinitialize the new page flow
+                // 2. persiste the new page flow in the session.  Note, this causes the "destroy" lifecycle
+                //    method to be invoked on the previous page flow which is still in the session.
+                // 3. if the page flow is newly created, invoke its "create" lifecycle method.
+                //
+                // Note, steps 2 and 3 must happen in this order in order to remove the previous page flow from
+                // the session before adding the new one.
+                //
+                // For example, this code will execute when forwarding from an existing Page Flow to a new Page Flow
                 //
                 retVal.reinitialize( request, response, servletContext );
                 retVal.persistInSession( request, response );
-                if ( createdNew ) retVal.create( request, response, servletContext );
+                if ( createdNew ) 
+                    retVal.create( request, response, servletContext );
             }
         }
 

Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java?rev=392179&r1=392178&r2=392179&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java Thu Apr  6 21:26:58 2006
@@ -17,24 +17,19 @@
  */
 package org.apache.beehive.netui.pageflow;
 
-import org.apache.beehive.netui.util.internal.InternalStringBuilder;
-
+import java.lang.reflect.Field;
+import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSessionBindingEvent;
 import javax.servlet.ServletContext;
-import java.lang.reflect.Field;
-import java.util.Map;
 
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionMapping;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.config.ModuleConfig;
 import org.apache.struts.config.ControllerConfig;
-import org.apache.beehive.netui.util.logging.Logger;
-import org.apache.beehive.netui.util.internal.FileUtils;
-import org.apache.beehive.netui.util.internal.DiscoveryUtils;
-import org.apache.beehive.netui.util.internal.cache.ClassLevelCache;
+import org.apache.beehive.controls.api.context.ControlContainerContext;
 import org.apache.beehive.netui.pageflow.config.PageFlowControllerConfig;
 import org.apache.beehive.netui.pageflow.config.PageFlowExceptionConfig;
 import org.apache.beehive.netui.pageflow.internal.CachedPageFlowInfo;
@@ -46,8 +41,11 @@
 import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils;
 import org.apache.beehive.netui.pageflow.handler.StorageHandler;
 import org.apache.beehive.netui.pageflow.handler.Handlers;
-import org.apache.beehive.controls.api.context.ControlContainerContext;
-
+import org.apache.beehive.netui.util.internal.DiscoveryUtils;
+import org.apache.beehive.netui.util.internal.cache.ClassLevelCache;
+import org.apache.beehive.netui.util.internal.FileUtils;
+import org.apache.beehive.netui.util.internal.InternalStringBuilder;
+import org.apache.beehive.netui.util.logging.Logger;
 
 /**
  * <p>
@@ -221,17 +219,21 @@
     {
         PageFlowController currentPageFlow = PageFlowUtils.getCurrentPageFlow( request, getServletContext() );
 
+        //
+        // This code implicitly destroys the current page flow.  In order to prevent multiple threads
+        // from executing inside the JPF at once, synchronize on it in order to complete the "destroy"
+        // atomically.
+        //
         if ( currentPageFlow != null && ! currentPageFlow.isOnNestingStack() )
         {
-            //
-            // We're going to be implicitly destroying the current page flow.  Synchronize on it so we don't mess
-            // with concurrent requests.
-            //
             synchronized ( currentPageFlow )
             {
                 InternalUtils.setCurrentPageFlow( this, request, getServletContext() );
             }
         }
+        //
+        // Here, there is no previous page flow to syncyronize upon before destruction
+        //
         else
         {
             InternalUtils.setCurrentPageFlow( this, request, getServletContext() );
@@ -239,12 +241,17 @@
     }
 
     /**
-     * Ensures that any changes to this object will be replicated in a cluster (for failover),
-     * even if the replication scheme uses a change-detection algorithm that relies on
-     * HttpSession.setAttribute to be aware of changes.  Note that this method is used by the framework
-     * and does not need to be called explicitly in most cases.
-     * 
-     * @param request the current HttpServletRequest
+     * <p>
+     * Ensure that any changes to this object will be replicated in a cluster (for failover), even if the
+     * replication scheme uses a change-detection algorithm that relies on
+     * {@link javax.servlet.http.HttpSession#setAttribute(String, Object)} to be aware of changes.  This method is
+     * used by the framework and should not be called directly in most cases.
+     * </p>
+     * <p>
+     * Note, this method ultimately causes the Page Flow to be persisted in the {@link javax.servlet.http.HttpSession}.
+     * </p>
+     *
+     * @param request the current {@link HttpServletRequest}
      */
     public void ensureFailover( HttpServletRequest request )
     {
@@ -260,7 +267,8 @@
             RequestContext rc = new RequestContext( unwrappedRequest, null );
 
             //
-            // If this is a long-lived page flow, there are two attributes to deal with.
+            // If this is a long-lived page flow, there are two attributes to deal with, and ensure that
+            // both failover correctly.
             //
             if ( isLongLived() )
             {
@@ -271,6 +279,9 @@
                 sh.ensureFailover( rc, longLivedAttrName, this );
                 sh.ensureFailover( rc, currentLongLivedAttrName, getModulePath() );
             }
+            //
+            // This Page Flow is not long lived, so just the Page Flow itself needs to be added to the session.
+            //
             else
             {
                 String attrName = ScopedServletUtils.getScopedSessionAttrName( CURRENT_JPF_ATTR, unwrappedRequest );
@@ -282,7 +293,9 @@
     /**
      * @exclude
      */
-    protected ActionForward internalExecute( ActionMapping mapping, ActionForm form, HttpServletRequest request,
+    protected ActionForward internalExecute( ActionMapping mapping,
+                                             ActionForm form,
+                                             HttpServletRequest request,
                                              HttpServletResponse response )
         throws Exception
     {
@@ -386,7 +399,8 @@
      * This is a framework method for initializing a newly-created page flow, and should not normally be called
      * directly.
      */
-    public final synchronized void create( HttpServletRequest request, HttpServletResponse response,
+    public final synchronized void create( HttpServletRequest request,
+                                           HttpServletResponse response,
                                            ServletContext servletContext )
     {
         reinitialize( request, response, servletContext );
@@ -1107,4 +1121,4 @@
     private void setReturnActionViewRenderer(ViewRenderer returnActionViewRenderer) {
         _returnActionViewRenderer = returnActionViewRenderer;
     }
-}
+}
\ No newline at end of file

Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowManagedObject.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowManagedObject.java?rev=392179&r1=392178&r2=392179&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowManagedObject.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowManagedObject.java Thu Apr  6 21:26:58 2006
@@ -120,7 +120,7 @@
 
     /**
      * Callback when this object is removed from the user session.  Causes {@link #onDestroy} to be called.  This is a
-     * framework-invoked method that should not normally be called directly.
+     * framework-invoked method that should not be called directly.
      */ 
     public void valueUnbound( HttpSessionBindingEvent event )
     {

Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java?rev=392179&r1=392178&r2=392179&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowRequestProcessor.java Thu Apr  6 21:26:58 2006
@@ -399,7 +399,7 @@
 
         String uri = InternalUtils.getDecodedServletPath( request );
         ServletContext servletContext = getServletContext();
-        
+
         // The ServletContainerAdapter reference may have been lost during serialization/deserialization.
         if (_servletContainerAdapter == null) {
             _servletContainerAdapter = AdapterManager.getServletContainerAdapter( servletContext );
@@ -502,6 +502,7 @@
             RequestContext requestContext = new RequestContext( request, response );
             Map/*< String, SharedFlowController >*/ sharedFlows =
                     _flowControllerFactory.getSharedFlowsForRequest( requestContext );
+            /* todo: why are the shared flow / global app objects loaded for data binding here? */
             ImplicitObjectUtil.loadSharedFlow( request, sharedFlows );
             ImplicitObjectUtil.loadGlobalApp( request, PageFlowUtils.getGlobalApp( request ) );
 

Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DeferredSessionStorageHandler.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DeferredSessionStorageHandler.java?rev=392179&r1=392178&r2=392179&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DeferredSessionStorageHandler.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/DeferredSessionStorageHandler.java Thu Apr  6 21:26:58 2006
@@ -110,8 +110,13 @@
         request.setAttribute( attrName, value );
         getChangedAttributesList( request, true, false ).add( attrName );
 
+        //
+        // For attributes that have changed and are now tracked in the changed attribute list, be sure to remove
+        // them from the list of failover attributes.
+        //
         HashMap failoverAttrs = getFailoverAttributesMap( request, false, false );
-        if ( failoverAttrs != null ) failoverAttrs.remove( attrName );
+        if ( failoverAttrs != null )
+            failoverAttrs.remove( attrName );
     }
 
     public void removeAttribute( RequestContext context, String attrName )
@@ -188,7 +193,7 @@
         if ( changedAttrs != null )
         {
             //
-            // Go through each changed attribute, and either write it to the session or remove it to the session,
+            // Go through each changed attribute, and either write it to the session or remove it from the session,
             // depending on whether or not it exists in the request.
             //
             for ( Iterator i = changedAttrs.iterator(); i.hasNext(); )

Modified: beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java?rev=392179&r1=392178&r2=392179&view=diff
==============================================================================
--- beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java (original)
+++ beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/internal/InternalUtils.java Thu Apr  6 21:26:58 2006
@@ -687,9 +687,9 @@
     }
 
     /**
-     * Set the current ActionResolver ({@link PageFlowController}) in the user session.
+     * Set the current {@link ActionResolver} (or {@link PageFlowController}) in the user session.
      *
-     * @param resolver the ActionResolver to set as the current one in the user session.
+     * @param resolver the {@link ActionResolver} to set as the current one in the user session.
      * @deprecated Will be removed in the next version.
      */
     public static void setCurrentActionResolver( ActionResolver resolver, HttpServletRequest request,
@@ -702,6 +702,9 @@
         String currentLongLivedJpfAttrName =
                 ScopedServletUtils.getScopedSessionAttrName( CURRENT_LONGLIVED_ATTR, unwrappedRequest );
 
+        //
+        // This case occurs when the previous page flow is no longer active and there is no new page flow
+        //
         if ( resolver == null )
         {
             sh.removeAttribute( rc, currentJpfAttrName );
@@ -727,6 +730,9 @@
             sh.setAttribute( rc, currentLongLivedJpfAttrName, resolver.getModulePath() );
             sh.removeAttribute( rc, currentJpfAttrName );
         }
+        //
+        // Default case for removing a previous page flow in the presence of a new page flow.
+        //
         else
         {
             sh.setAttribute( rc, currentJpfAttrName, resolver );