portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r388702 - in /portals/jetspeed-2/trunk: components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/ components/portal/src/java/org/apache/jetspeed/profiler/impl/ jetspeed-api/src/java/org/apache/jetspeed/portalsite/
Date Sat, 25 Mar 2006 04:40:45 GMT
Author: rwatler
Date: Fri Mar 24 20:40:44 2006
New Revision: 388702

URL: http://svn.apache.org/viewcvs?rev=388702&view=rev
Log:
document PortalSiteContextImpl as Serializable, albeit now
with transient members that are tested for non-null values
to determine if context is valid before use; this is done in
case the PortalSiteContextImpl is loaded from the persistent
store or is recovered/duplicated from another clustered J2
server and is empty/invaild


Modified:
    portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/portalsite/PortalSiteSessionContext.java

Modified: portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java?rev=388702&r1=388701&r2=388702&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
Fri Mar 24 20:40:44 2006
@@ -15,6 +15,7 @@
  */
 package org.apache.jetspeed.portalsite.impl;
 
+import java.io.Serializable;
 import java.security.AccessController;
 import java.security.Principal;
 import java.util.HashMap;
@@ -51,12 +52,26 @@
 /**
  * This class encapsulates managed session state for and
  * interface to the portal-site component and subscribes
- * to page manager and session events to flush stale state
+ * to page manager and session events to flush stale state.
+ *
+ * Note that is object is Serializable since it is designed
+ * to be cached in the session. However, because this object
+ * is cached only for these two reasons:
+ *
+ * 1. a performance optimization to reuse SiteViews, and 
+ * 2. to hold optional folder page history,
+ *
+ * this object need not be relocatable between J2 instances.
+ * Consequently, all data members are marked transient and
+ * the isValid() method is used to test whether this object
+ * is a valid context for the session or if it was
+ * transferred from another server or the persistent session
+ * store and needs to be discarded.
  * 
  * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
  * @version $Id$
  */
-public class PortalSiteSessionContextImpl implements PortalSiteSessionContext, PageManagerEventListener,
HttpSessionActivationListener, HttpSessionBindingListener
+public class PortalSiteSessionContextImpl implements PortalSiteSessionContext, PageManagerEventListener,
HttpSessionActivationListener, HttpSessionBindingListener, Serializable
 {
     /**
      * log - logging instance
@@ -66,45 +81,45 @@
     /**
      * pageManager - PageManager component
      */
-    private PageManager pageManager;
+    private transient PageManager pageManager;
 
     /**
      * profileLocators - map of session profile locators by locator names
      */
-    private Map profileLocators;
+    private transient Map profileLocators;
 
     /**
      * userPrincipal - session user principal
      */
-    private String userPrincipal;
+    private transient String userPrincipal;
 
     /**
      * siteView - session site view
      */
-    private SiteView siteView;
+    private transient SiteView siteView;
 
     /**
      * folderPageHistory - map of last page visited by folder 
      */
-    private Map folderPageHistory;
+    private transient Map folderPageHistory;
 
     /**
      * menuDefinitionLocatorCache - cached menu definition locators for
      *                              absolute menus valid for session
      */
-    private Map menuDefinitionLocatorCache;
+    private transient Map menuDefinitionLocatorCache;
 
     /**
      * subscribed - flag that indicates whether this context
      *              is subscribed as event listeners
      */
-    private boolean subscribed;
+    private transient boolean subscribed;
 
     /**
      * stale - flag that indicates whether the state
      *         managed by this context is stale
      */
-    private boolean stale;
+    private transient boolean stale;
 
     /**
      * PortalSiteSessionContextImpl - constructor
@@ -802,6 +817,19 @@
     public PageManager getPageManager()
     {
         return pageManager;
+    }
+
+    /**
+     * isValid - return flag indicating whether this context instance
+     *           is valid or if it is stale after being persisted and
+     *           reloaded as session state
+     *
+     * @return valid context status
+     */
+    public boolean isValid()
+    {
+        // existant transient page manager implies valid context 
+        return (pageManager != null);
     }
 
     /**

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java?rev=388702&r1=388701&r2=388702&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
Fri Mar 24 20:40:44 2006
@@ -178,9 +178,12 @@
                 // used to build site menus from its extent; this is
                 // cached in the session because locators seldom change
                 // during the session so the session view of the site can
-                // be cached unless locators do change;
+                // be cached unless locators do change; if the context
+                // is invalid, (perhaps because the session was persisted
+                // and is now being reloaded in a new server), it must be
+                // replaced with a newly created session context
                 PortalSiteSessionContext sessionContext = (PortalSiteSessionContext)request.getSessionAttribute(PORTAL_SITE_SESSION_CONTEXT_ATTR_KEY);
-                if (sessionContext == null)
+                if ((sessionContext == null) || !sessionContext.isValid())
                 {
                     sessionContext = portalSite.newSessionContext();
                     request.setSessionAttribute(PORTAL_SITE_SESSION_CONTEXT_ATTR_KEY, sessionContext);

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/portalsite/PortalSiteSessionContext.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/portalsite/PortalSiteSessionContext.java?rev=388702&r1=388701&r2=388702&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/portalsite/PortalSiteSessionContext.java
(original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/portalsite/PortalSiteSessionContext.java
Fri Mar 24 20:40:44 2006
@@ -52,4 +52,13 @@
      * @return PageManager instance
      */
     PageManager getPageManager();
+
+    /**
+     * isValid - return flag indicating whether this context instance
+     *           is valid or if it is stale after being persisted and
+     *           reloaded as session state
+     *
+     * @return valid context status
+     */
+    boolean isValid();
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message