portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r995680 [1/2] - in /portals/jetspeed-2/portal/trunk: components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/ components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/ components/jetspeed-page-manager/src/...
Date Fri, 10 Sep 2010 06:14:23 GMT
Author: rwatler
Date: Fri Sep 10 06:14:22 2010
New Revision: 995680

URL: http://svn.apache.org/viewvc?rev=995680&view=rev
Log:
Jetspeed DBPM Cache Implementation Improvements
-------------------------------------------------------------
- Use EhCache LRU settings for cache memory store eviction policy, (LFU is not generally compatible with element expiration).
- Use "classic" EhCache LRU configuration, (Cache.NET_SF_EHCACHE_USE_CLASSIC_LRU = "true"), for stable cache eviction.
- Implement weak references for Portal Site Page and Folder Proxies to prevent excess DBPM object footprints outside of cache.
- Implement "stale" flag on DBPM objects that gets set on cache eviction to help Portal Site Page and Folder Proxies let go
  of evicted/expired objects and be more responsive to distributed writes.
- Add logic to DbPM cache to freshen Folder nodes in the LRU cache when accessed via "parent" navigation to keep system and root
  folders from being evicted from cache when they should be considered accessed whenever child nodes are.
- Extends PortalAdminstration component to allow creation of deep user folders when parent folders do not exist: facilitates
  subsite test configuration setup.


Added:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderWeakReference.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/DynamicPageWeakReference.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/FragmentDefinitionWeakReference.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/LinkWeakReference.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageTemplateWeakReference.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageWeakReference.java
Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhCacheConfigResource.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseElementImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseElement.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/document/impl/NodeImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/resources/JETSPEED-INF/ojb/page-manager-repository.xml
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/resources/distributed-ehcache.xml
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/resources/ehcache.xml
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/DynamicPageProxy.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/FragmentDefinitionProxy.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/LinkProxy.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageProxy.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageTemplateProxy.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/BaseElement.java
    portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/db-ojb/distributed-ehcache.xml
    portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/db-ojb/ehcache.xml

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhCacheConfigResource.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhCacheConfigResource.java?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhCacheConfigResource.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhCacheConfigResource.java Fri Sep 10 06:14:22 2010
@@ -23,6 +23,8 @@ import java.net.URL;
 import java.util.Map;
 import java.util.HashMap;
 
+import net.sf.ehcache.Cache;
+
 import org.springframework.core.io.AbstractResource;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.Resource;
@@ -118,6 +120,16 @@ public class EhCacheConfigResource exten
     {
         synchronized (EhCacheConfigResource.class)
         {
+            // set global EhCache properties configuration
+            //
+            // Use "classic" LRU implementation based on java's LinkedHashMap
+            // with accessOrder mode enabled. Do not remove this setting casually
+            // without verifying proper cache operation under load. EhCache
+            // supplied LRU and LFU modes in 1.7.2 do not fare as well under load
+            // and result in objects not remaining in the cache for long enough
+            // intervals, especially after being forcibly expired out of the cache.
+            System.setProperty(Cache.NET_SF_EHCACHE_USE_CLASSIC_LRU, "true");
+            
             // copy specified configuration settings
             if (configuration != null)
             {

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseElementImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseElementImpl.java?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseElementImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/BaseElementImpl.java Fri Sep 10 06:14:22 2010
@@ -57,6 +57,7 @@ public abstract class BaseElementImpl im
     private boolean constraintsEnabled;
     private boolean permissionsEnabled;
     private PageManager pageManager;
+    private volatile boolean stale;
     protected static PermissionFactory pf;
     
     public static void setPermissionsFactory(PermissionFactory pf)
@@ -134,6 +135,16 @@ public abstract class BaseElementImpl im
     }     
 
     /**
+     * Set stale status of this object.
+     * 
+     * @param stale stale flag status
+     */
+    public void setStale(boolean stale)
+    {
+        this.stale = stale;
+    }
+    
+    /**
      * grantViewActionAccess
      *
      * @return granted access for view action
@@ -547,4 +558,12 @@ public abstract class BaseElementImpl im
     {
         this.shortTitle = shortTitle;
     }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseElement#isStale()
+     */
+    public boolean isStale()
+    {
+        return stale;
+    }
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseElement.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseElement.java?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseElement.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseElement.java Fri Sep 10 06:14:22 2010
@@ -145,6 +145,19 @@ public abstract class AbstractBaseElemen
 
     /**
      * <p>
+     * isStale
+     * </p>
+     *
+     * @see org.apache.jetspeed.om.page.BaseElement#isStale()
+     */
+    public boolean isStale()
+    {
+        // file based PSML instances never considered stale
+        return false;
+    }
+
+    /**
+     * <p>
      * getConstraintsEnabled
      * </p>
      *

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/document/impl/NodeImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/document/impl/NodeImpl.java?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/document/impl/NodeImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/document/impl/NodeImpl.java Fri Sep 10 06:14:22 2010
@@ -39,6 +39,7 @@ import org.apache.ojb.broker.core.proxy.
  */
 public abstract class NodeImpl extends BaseElementImpl implements Node
 {
+    private Integer parentId;
     private Node parent;
     private boolean hidden;
     private Collection metadataFields;
@@ -375,6 +376,18 @@ public abstract class NodeImpl extends B
         return path;
     }
 
+    /**
+     * getParentIdentity
+     * 
+     * Access the parent identity saved to facilitate cache management.
+     * 
+     * @return parent identity or null if not available
+     */
+    public Integer getParentIdentity()
+    {
+        return parentId;
+    }
+
     /* (non-Javadoc)
      * @see org.apache.jetspeed.page.document.Node#getParent()
      */

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java Fri Sep 10 06:14:22 2010
@@ -58,6 +58,7 @@ public class DatabasePageManagerCache im
     
     private static JetspeedCache oidCache;
     private static JetspeedCache pathCache;
+    private static Map pathToOidMap;
     private static JetspeedCache propertiesCache;
     private static JetspeedCache propertiesPathCache;
     private static JetspeedCache principalPropertiesCache;
@@ -84,6 +85,7 @@ public class DatabasePageManagerCache im
         // initialize
         DatabasePageManagerCache.oidCache = oidCache;
         DatabasePageManagerCache.pathCache = pathCache;
+        DatabasePageManagerCache.pathToOidMap = new HashMap();
         DatabasePageManagerCache.propertiesCache = propertiesCache;
         DatabasePageManagerCache.propertiesPathCache = propertiesPathCache;
         DatabasePageManagerCache.principalPropertiesCache = principalPropertiesCache;
@@ -103,6 +105,7 @@ public class DatabasePageManagerCache im
             public void notifyElementAdded(JetspeedCache cache, boolean local, Object key, Object element)
             {
                 NodeImpl node = (NodeImpl)element;
+                pathToOidMap.put(node.getPath(), (Identity)key);
                 // infuse node with page manager configuration
                 // or the page manager itself and add to the
                 // paths cache
@@ -141,6 +144,10 @@ public class DatabasePageManagerCache im
             public void notifyElementRemoved(JetspeedCache cache, boolean local, Object key, Object element)
             {
                 NodeImpl node = (NodeImpl)element;
+                pathToOidMap.remove(node.getPath());
+                // set stale flag since this object will now be orphaned
+                // and should be be refetched from the page manager
+                node.setStale(true);
                 // reset internal FolderImpl caches
                 if (node instanceof FolderImpl)
                 {
@@ -196,7 +203,7 @@ public class DatabasePageManagerCache im
                         if (oid != null)
                         {
                             // get object cached by oid
-                            NodeImpl node = (NodeImpl)cacheLookup(oid);
+                            NodeImpl node = cacheLookup(oid, false);
                             // reset internal FolderImpl caches
                             if (node instanceof FolderImpl)
                             {
@@ -205,14 +212,14 @@ public class DatabasePageManagerCache im
                             // notify page manager of update
                             DatabasePageManagerCache.pageManager.notifyUpdatedNode(node);
                             // remove from cache
-                            DatabasePageManagerCache.oidCache.removeQuiet(oid);
+                            DatabasePageManagerCache.oidCache.remove(oid);
                         }
                         if (path != null)
                         {
                             // lookup parent object cached by path and oid
                             int pathLastSeparatorIndex = path.lastIndexOf(Folder.PATH_SEPARATOR);
                             String parentPath = ((pathLastSeparatorIndex > 0) ? path.substring(0, pathLastSeparatorIndex) : Folder.PATH_SEPARATOR);
-                            NodeImpl parentNode = cacheLookup(parentPath);
+                            NodeImpl parentNode = cacheLookup(parentPath, false);
                             // reset internal FolderImpl caches in case element removed
                             if (parentNode instanceof FolderImpl)
                             {
@@ -539,21 +546,33 @@ public class DatabasePageManagerCache im
     }
 
     /**
-     * Lookup object instances by unique path.
+     * Lookup node instances by unique path and consider 
+     * cache access application read hit.
      *
      * @param path node unique path
      * @return cached node
      */
     public synchronized static NodeImpl cacheLookup(String path)
     {
+        return cacheLookup(path, true);
+    }
+
+    /**
+     * Lookup node instances by unique path.
+     *
+     * @param path node unique path
+     * @param cacheRead application cache read hit
+     * @return cached node
+     */
+    private synchronized static NodeImpl cacheLookup(String path, boolean cacheRead)
+    {
         if (path != null)
         {
             // return valid object cached by path and oid
-            CacheElement pathElement = pathCache.get(path);
-            if (pathElement != null)
+            Identity oid = (Identity)pathToOidMap.get(path);
+            if (oid != null)
             {
-                DatabasePageManagerCacheObject cacheObject = (DatabasePageManagerCacheObject)pathElement.getContent();
-                return (NodeImpl)cacheLookup(cacheObject.getId());
+                return cacheLookup(oid, cacheRead);
             }
         }
         return null;
@@ -573,42 +592,38 @@ public class DatabasePageManagerCache im
     }
 
     /**
-     * Add object to cache and cache instances by unique path;
+     * Add node to cache and cache instances by unique path;
      * infuse nodes loaded by OJB with page manager configuration.
      *
      * @param oid object/node identity
      * @param obj object/node to cache
      */
-    public synchronized static void cacheAdd(Identity oid, Object obj)
+    private synchronized static void cacheAdd(Identity oid, NodeImpl node)
     {
-        if (obj instanceof NodeImpl)
-        {
-            NodeImpl node = (NodeImpl)obj;
-            String path = node.getPath();
+        String path = node.getPath();
 
-            // add node to caches; note that removes force notification
-            // of update to distributed caches
-            oidCache.remove(oid);
-            boolean removed = pathCache.remove(path);
-            CacheElement pathElement = pathCache.createElement(path, new DatabasePageManagerCacheObject(oid, path));
+        // add node to caches; note that removes force notification
+        // of update to distributed caches
+        oidCache.remove(oid);
+        boolean removed = pathCache.remove(path);
+        CacheElement pathElement = pathCache.createElement(path, new DatabasePageManagerCacheObject(oid, path));
+        pathCache.put(pathElement);
+        // if a remove was not successful from the path cache, update
+        // notification to distributed peers was not performed;
+        // for updates of objects evicted from the cache or newly
+        // created ones, this is problematic: remove and put into
+        // path cache a second time to force
+        if (!removed && updatePathsList.contains(path))
+        {
+            pathCache.remove(path);
             pathCache.put(pathElement);
-            // if a remove was not successful from the path cache, update
-            // notification to distributed peers was not performed;
-            // for updates of objects evicted from the cache or newly
-            // created ones, this is problematic: remove and put into
-            // path cache a second time to force
-            if (!removed && updatePathsList.contains(path))
-            {
-                pathCache.remove(path);
-                pathCache.put(pathElement);
-            }
-            // add node to local oid cache by key after removes from
-            // distributed path cache since those removes will remove
-            // from local oid cache in notifications, (despite the
-            // 'local' listener registration)
-            CacheElement element = oidCache.createElement(oid, node);
-            oidCache.put(element);
         }
+        // add node to local oid cache by key after removes from
+        // distributed path cache since those removes will remove
+        // from local oid cache in notifications, (despite the
+        // 'local' listener registration)
+        CacheElement element = oidCache.createElement(oid, node);
+        oidCache.put(element);
     }
 
     /**
@@ -627,6 +642,8 @@ public class DatabasePageManagerCache im
      */
     public synchronized static void cacheClear()
     {
+        // clear localally managed mappings
+        pathToOidMap.clear();
         // remove all items from oid and properties caches
         // individually to ensure notifications are run to
         // detach elements; do not invoke JetspeedCache.clear()
@@ -667,12 +684,13 @@ public class DatabasePageManagerCache im
     }
 
     /**
-     * Lookup objects by identity.
+     * Lookup node by identity.
      *
-     * @param oid object identity
-     * @return cached object
+     * @param oid node identity
+     * @param cacheRead application cache read hit
+     * @return cached node
      */
-    public synchronized static Object cacheLookup(Identity oid)
+    private synchronized static NodeImpl cacheLookup(Identity oid, boolean cacheRead)
     {
         if (oid != null)
         {
@@ -680,7 +698,45 @@ public class DatabasePageManagerCache im
             CacheElement element = oidCache.get(oid);
             if (element != null)
             {
-                return element.getContent();
+                NodeImpl node = (NodeImpl)element.getContent();
+
+                // if cache access is considered an application
+                // read hit, ping elements in oid and path caches
+                // related to retrieved node to prevent them from
+                // being LRU reaped from the cache and limit
+                // cache churn, heap bloat, and graph calving
+                if (cacheRead)
+                {
+                    // ping node path cache element
+                    String path = node.getPath();
+                    pathCache.get(path);
+                    // iterate up cached parent folder hierarchy
+                    Integer parentIdentity = node.getParentIdentity();
+                    while (parentIdentity != null)
+                    {
+                        // access parent node by oid from cache and ping
+                        // parent oid cache element in the process
+                        Identity parentOid = new Identity(FolderImpl.class, FolderImpl.class, new Object[]{new Integer(parentIdentity)});
+                        CacheElement parentElement = oidCache.get(parentOid);
+                        if (parentElement != null)
+                        {
+                            // ping parent node path cache element
+                            NodeImpl parentNode = (NodeImpl)parentElement.getContent();
+                            String parentPath = parentNode.getPath();
+                            pathCache.get(parentPath);
+                            // get parent identity if available
+                            parentIdentity = parentNode.getParentIdentity();
+                        }
+                        else
+                        {
+                            // parent folder no longer in cache, will reload in
+                            // cache when parent folder is subsequently accessed
+                            break;
+                        }
+                    }
+                }
+                
+                return node;
             }
         }
         return null;
@@ -696,7 +752,7 @@ public class DatabasePageManagerCache im
         // remove from cache by oid
         if (oid != null)
         {
-            NodeImpl node = (NodeImpl)cacheLookup(oid);
+            NodeImpl node = cacheLookup(oid, false);
             if (node != null)
             {
                 String path = node.getPath();
@@ -728,13 +784,19 @@ public class DatabasePageManagerCache im
         // remove from cache by path
         if (path != null)
         {
+            // remove from oid cache
+            Identity oid = (Identity)pathToOidMap.get(path);
+            if (oid != null)
+            {
+                oidCache.remove(oid);
+            }
+            // remove from path cache
             CacheElement pathElement = pathCache.get(path);
             if (pathElement != null)
             {
                 DatabasePageManagerCacheObject cacheObject = (DatabasePageManagerCacheObject)pathElement.getContent();
                 // remove from caches; note that removes are
                 // propagated to distributed caches
-                oidCache.remove(cacheObject.getId());
                 pathCache.remove(path);
             }
             else
@@ -759,7 +821,7 @@ public class DatabasePageManagerCache im
         Iterator resetIter = oidCache.getKeys().iterator();
         while (resetIter.hasNext())
         {
-            NodeImpl node = (NodeImpl)cacheLookup((Identity)resetIter.next());
+            NodeImpl node = cacheLookup((Identity)resetIter.next(), false);
             if (node != null)
             {
             	node.resetCachedSecurityConstraints();
@@ -1030,7 +1092,10 @@ public class DatabasePageManagerCache im
      */
     public void cache(Identity oid, Object obj)
     {
-        cacheAdd(oid, obj);
+        if (obj instanceof NodeImpl)
+        {
+            cacheAdd(oid, (NodeImpl)obj);
+        }
     }
 
     /* (non-Javadoc)
@@ -1046,7 +1111,7 @@ public class DatabasePageManagerCache im
      */
     public Object lookup(Identity oid)
     {
-        return cacheLookup(oid);
+        return cacheLookup(oid, true);
     }
 
     /* (non-Javadoc)
@@ -1070,7 +1135,7 @@ public class DatabasePageManagerCache im
         while (dumpIter.hasNext())
         {
             Identity oid = (Identity)dumpIter.next();
-            NodeImpl node = (NodeImpl)cacheLookup(oid);
+            NodeImpl node = cacheLookup(oid, false);
             dump.append("node="+node.getPath()+", oid="+oid+EOL);
         }
         dump.append("--------------------------");

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/resources/JETSPEED-INF/ojb/page-manager-repository.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/resources/JETSPEED-INF/ojb/page-manager-repository.xml?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/resources/JETSPEED-INF/ojb/page-manager-repository.xml (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/resources/JETSPEED-INF/ojb/page-manager-repository.xml Fri Sep 10 06:14:22 2010
@@ -38,7 +38,6 @@
         name="parentId"
         column="PARENT_ID"
         jdbc-type="INTEGER"
-        access="anonymous"
       />
 
       <reference-descriptor
@@ -805,7 +804,6 @@
         name="parentId"
         column="PARENT_ID"
         jdbc-type="INTEGER"
-        access="anonymous"
       />
 
       <reference-descriptor
@@ -976,7 +974,6 @@
         name="parentId"
         column="PARENT_ID"
         jdbc-type="INTEGER"
-        access="anonymous"
       />
 
       <reference-descriptor
@@ -1188,7 +1185,6 @@
         name="parentId"
         column="PARENT_ID"
         jdbc-type="INTEGER"
-        access="anonymous"
       />
 
       <reference-descriptor
@@ -1391,7 +1387,6 @@
         name="parentId"
         column="PARENT_ID"
         jdbc-type="INTEGER"
-        access="anonymous"
       />
 
       <reference-descriptor
@@ -2893,7 +2888,6 @@
         name="parentId"
         column="PARENT_ID"
         jdbc-type="INTEGER"
-        access="anonymous"
       />
 
       <reference-descriptor
@@ -3198,7 +3192,6 @@
         name="parentId"
         column="PARENT_ID"
         jdbc-type="INTEGER"
-        access="anonymous"
       />
 
       <reference-descriptor

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/resources/distributed-ehcache.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/resources/distributed-ehcache.xml?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/resources/distributed-ehcache.xml (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/resources/distributed-ehcache.xml Fri Sep 10 06:14:22 2010
@@ -49,7 +49,7 @@
            overflowToDisk="false"
            timeToIdleSeconds="${org.apache.jetspeed.ehcache.pagemanager.element.ttl}"
            timeToLiveSeconds="${org.apache.jetspeed.ehcache.pagemanager.element.ttl}"
-           memoryStoreEvictionPolicy="LFU"/>
+           memoryStoreEvictionPolicy="LRU"/>
 
     <cache name="pageManagerPathCache"
            maxElementsInMemory="${org.apache.jetspeed.ehcache.pagemanager.maxelements}"
@@ -57,7 +57,7 @@
            overflowToDisk="false"
            timeToIdleSeconds="${org.apache.jetspeed.ehcache.pagemanager.element.ttl}"
            timeToLiveSeconds="${org.apache.jetspeed.ehcache.pagemanager.element.ttl}"
-           memoryStoreEvictionPolicy="LFU">
+           memoryStoreEvictionPolicy="LRU">
         <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
                                    properties="replicateAsynchronously=true,
                                                replicatePuts=false,
@@ -72,7 +72,7 @@
            overflowToDisk="false"
            timeToIdleSeconds="${org.apache.jetspeed.ehcache.pagemanager.element.ttl}"
            timeToLiveSeconds="${org.apache.jetspeed.ehcache.pagemanager.element.ttl}"
-           memoryStoreEvictionPolicy="LFU"/>
+           memoryStoreEvictionPolicy="LRU"/>
 
     <cache name="pageManagerPropertiesPathCache"
            maxElementsInMemory="${org.apache.jetspeed.ehcache.pagemanager.maxelements}"
@@ -80,7 +80,7 @@
            overflowToDisk="false"
            timeToIdleSeconds="${org.apache.jetspeed.ehcache.pagemanager.element.ttl}"
            timeToLiveSeconds="${org.apache.jetspeed.ehcache.pagemanager.element.ttl}"
-           memoryStoreEvictionPolicy="LFU">
+           memoryStoreEvictionPolicy="LRU">
         <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
                                    properties="replicateAsynchronously=true,
                                                replicatePuts=false,
@@ -95,7 +95,7 @@
            overflowToDisk="false"
            timeToIdleSeconds="${org.apache.jetspeed.ehcache.pagemanager.element.ttl}"
            timeToLiveSeconds="${org.apache.jetspeed.ehcache.pagemanager.element.ttl}"
-           memoryStoreEvictionPolicy="LFU"/>
+           memoryStoreEvictionPolicy="LRU"/>
 
     <cache name="pageManagerPrincipalPropertiesPathCache"
            maxElementsInMemory="${org.apache.jetspeed.ehcache.pagemanager.maxelements}"
@@ -103,7 +103,7 @@
            overflowToDisk="false"
            timeToIdleSeconds="${org.apache.jetspeed.ehcache.pagemanager.element.ttl}"
            timeToLiveSeconds="${org.apache.jetspeed.ehcache.pagemanager.element.ttl}"
-           memoryStoreEvictionPolicy="LFU">
+           memoryStoreEvictionPolicy="LRU">
         <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
                                    properties="replicateAsynchronously=true,
                                                replicatePuts=false,
@@ -118,6 +118,6 @@
            overflowToDisk="false"
            timeToIdleSeconds="0"
            timeToLiveSeconds="0"
-           memoryStoreEvictionPolicy="LFU"/>
+           memoryStoreEvictionPolicy="LRU"/>
 
 </ehcache>

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/resources/ehcache.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/resources/ehcache.xml?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/resources/ehcache.xml (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/test/resources/ehcache.xml Fri Sep 10 06:14:22 2010
@@ -38,7 +38,7 @@
            overflowToDisk="false"
            timeToIdleSeconds="150"
            timeToLiveSeconds="150"
-           memoryStoreEvictionPolicy="LFU"/>
+           memoryStoreEvictionPolicy="LRU"/>
 
     <cache name="pageManagerPathCache"
            maxElementsInMemory="128"
@@ -46,7 +46,7 @@
            overflowToDisk="false"
            timeToIdleSeconds="150"
            timeToLiveSeconds="150"
-           memoryStoreEvictionPolicy="LFU"/>
+           memoryStoreEvictionPolicy="LRU"/>
 
     <cache name="pageManagerPropertiesCache"
            maxElementsInMemory="128"
@@ -54,7 +54,7 @@
            overflowToDisk="false"
            timeToIdleSeconds="150"
            timeToLiveSeconds="150"
-           memoryStoreEvictionPolicy="LFU"/>
+           memoryStoreEvictionPolicy="LRU"/>
 
     <cache name="pageManagerPropertiesPathCache"
            maxElementsInMemory="128"
@@ -62,7 +62,7 @@
            overflowToDisk="false"
            timeToIdleSeconds="150"
            timeToLiveSeconds="150"
-           memoryStoreEvictionPolicy="LFU"/>
+           memoryStoreEvictionPolicy="LRU"/>
 
     <cache name="pageManagerPrincipalPropertiesCache"
            maxElementsInMemory="128"
@@ -70,7 +70,7 @@
            overflowToDisk="false"
            timeToIdleSeconds="150"
            timeToLiveSeconds="150"
-           memoryStoreEvictionPolicy="LFU"/>
+           memoryStoreEvictionPolicy="LRU"/>
 
     <cache name="pageManagerPrincipalPropertiesPathCache"
            maxElementsInMemory="128"
@@ -78,7 +78,7 @@
            overflowToDisk="false"
            timeToIdleSeconds="150"
            timeToLiveSeconds="150"
-           memoryStoreEvictionPolicy="LFU"/>
+           memoryStoreEvictionPolicy="LRU"/>
 
     <cache name="pageFileCache"
            maxElementsInMemory="100"
@@ -86,6 +86,6 @@
            overflowToDisk="false"
            timeToIdleSeconds="0"
            timeToLiveSeconds="0"
-           memoryStoreEvictionPolicy="LFU"/>
+           memoryStoreEvictionPolicy="LRU"/>
 
 </ehcache>

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderProxy.java Fri Sep 10 06:14:22 2010
@@ -40,6 +40,7 @@ import org.apache.jetspeed.om.page.proxy
 import org.apache.jetspeed.om.page.proxy.PageProxy;
 import org.apache.jetspeed.om.page.proxy.PageTemplateProxy;
 import org.apache.jetspeed.om.portlet.GenericMetadata;
+import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.page.PageNotFoundException;
 import org.apache.jetspeed.page.document.DocumentException;
 import org.apache.jetspeed.page.document.DocumentNotFoundException;
@@ -88,14 +89,14 @@ public class FolderProxy extends NodePro
     protected static final Method GET_TITLE_METHOD = reflectMethod(Folder.class, "getTitle", null);
 
     /**
-     * defaultFolder - default proxy delegate folder instance
+     * defaultFolderReference - default proxy delegate folder instance reference
      */
-    private Folder defaultFolder;
+    private FolderWeakReference defaultFolderReference;
 
     /**
-     * titledFolder - titled proxy delegate folder instance
+     * titledFolderReference - titled proxy delegate folder instance reference
      */
-    private Folder titledFolder;
+    private FolderWeakReference titledFolderReference;
 
     /**
      * forceReservedVisible - flag used to suppress child reserved/hidden folder visibility checks
@@ -173,17 +174,17 @@ public class FolderProxy extends NodePro
     private boolean linksAggregated;
 
     /**
-     * SearchFolder - data object used hold concrete search folder and
-     *                related search path profile locator name pairs
+     * SearchFolder - data object used hold concrete search folder reference
+     *                and related search path profile locator name pairs
      */
     private class SearchFolder
     {
-        public Folder folder;
+        public FolderWeakReference folderReference;
         public String locatorName;
 
-        public SearchFolder(Folder folder, String locatorName)
+        public SearchFolder(FolderWeakReference folderReference, String locatorName)
         {
-            this.folder = folder;
+            this.folderReference = folderReference;
             this.locatorName = locatorName;
         }
     }
@@ -196,16 +197,16 @@ public class FolderProxy extends NodePro
 
     /**
      * InheritanceFolder - data object used hold aggregated concrete search
-     *                     folders and view path to folder 
+     *                     folder references and view path to folder 
      */
     private class InheritanceFolder
     {
-        public Folder folder;
+        public FolderWeakReference folderReference;
         public String path;
 
-        public InheritanceFolder(Folder folder, String path)
+        public InheritanceFolder(FolderWeakReference folderReference, String path)
         {
-            this.folder = folder;
+            this.folderReference = folderReference;
             this.path = path;
         }
     }
@@ -244,8 +245,8 @@ public class FolderProxy extends NodePro
     private FolderProxy(SearchPathsSiteView view, String locatorName, Folder parentFolder, Folder folder, boolean forceReservedVisible)
     {
         super(view, locatorName, parentFolder, folder.getName(), folder.isHidden());
-        this.defaultFolder = selectDefaultFromAggregateFolders(folder);
-        this.titledFolder = selectTitledFromAggregateFolders(this.defaultFolder);
+        this.defaultFolderReference = selectDefaultFromAggregateFolders(folder);
+        this.titledFolderReference = selectTitledFromAggregateFolders(this.defaultFolderReference);
         this.forceReservedVisible = forceReservedVisible;
     }
     
@@ -385,7 +386,7 @@ public class FolderProxy extends NodePro
         try
         {
             // attempt to invoke method on delegate Folder instance
-            return m.invoke(defaultFolder, args);
+            return m.invoke(defaultFolderReference.getFolder(), args);
         }
         catch (InvocationTargetException ite)
         {
@@ -531,7 +532,7 @@ public class FolderProxy extends NodePro
         {
             return Folder.PATH_SEPARATOR;
         }
-        return defaultFolder.getName();
+        return defaultFolderReference.getFolder().getName();
     }
 
     /**
@@ -730,7 +731,7 @@ public class FolderProxy extends NodePro
     public GenericMetadata getMetadata()
     {
         // return titled concrete folder metadata
-        return titledFolder.getMetadata();
+        return titledFolderReference.getFolder().getMetadata();
     }
 
     /**
@@ -741,7 +742,7 @@ public class FolderProxy extends NodePro
     public String getTitle()
     {
         // return titled concrete folder title
-        return titledFolder.getTitle();
+        return titledFolderReference.getFolder().getTitle();
     }
 
     /**
@@ -752,7 +753,7 @@ public class FolderProxy extends NodePro
     public String getShortTitle()
     {
         // return titled concrete folder short title
-        return titledFolder.getShortTitle();
+        return titledFolderReference.getFolder().getShortTitle();
     }
 
     /**
@@ -764,7 +765,7 @@ public class FolderProxy extends NodePro
     public String getTitle(Locale locale)
     {
         // return titled concrete folder title
-        return titledFolder.getTitle(locale);
+        return titledFolderReference.getFolder().getTitle(locale);
     }
 
     /**
@@ -776,7 +777,7 @@ public class FolderProxy extends NodePro
     public String getShortTitle(Locale locale)
     {
         // return titled concrete folder short title
-        return titledFolder.getShortTitle(locale);
+        return titledFolderReference.getFolder().getShortTitle(locale);
     }
 
     /**
@@ -786,7 +787,7 @@ public class FolderProxy extends NodePro
      */
     public Folder getDefaultFolder()
     {
-        return defaultFolder;
+        return defaultFolderReference.getFolder();
     }
     
     /**
@@ -809,7 +810,7 @@ public class FolderProxy extends NodePro
             {
                 // test access against child in search folder
                 SearchFolder searchFolder = (SearchFolder)foldersIter.next();
-                Folder folder = searchFolder.folder;
+                Folder folder = searchFolder.folderReference.getFolder();
                 // ignore all folder access exceptions, (throws SecurityException on failed check access)
                 try
                 {
@@ -847,7 +848,7 @@ public class FolderProxy extends NodePro
             {
                 // test access against child in search folder
                 SearchFolder searchFolder = (SearchFolder)foldersIter.next();
-                Folder folder = searchFolder.folder;
+                Folder folder = searchFolder.folderReference.getFolder();
                 // ignore all folder access exceptions, (throws SecurityException on failed check access)
                 try
                 {
@@ -904,7 +905,7 @@ public class FolderProxy extends NodePro
                 // get menu definitions from inheritance folders and
                 // merge into aggregate menu definition locators
                 InheritanceFolder inheritanceFolder = (InheritanceFolder)inheritanceFoldersIter.next();
-                Folder folder = inheritanceFolder.folder;
+                Folder folder = inheritanceFolder.folderReference.getFolder();
                 String path = inheritanceFolder.path;
                 mergeMenuDefinitionLocators(folder.getMenuDefinitions(), folder, path, false);
             }
@@ -924,20 +925,20 @@ public class FolderProxy extends NodePro
      *                                     
      *
      * @param defaultFolder default concrete folder
-     * @return selected concrete folder
+     * @return selected concrete folder reference
      */
-    private Folder selectDefaultFromAggregateFolders(Folder defaultFolder)
+    private FolderWeakReference selectDefaultFromAggregateFolders(Folder defaultFolder)
     {
         // select most specific folder, (i.e. first) along
         // search paths ordered most to least specific
         try
         {
-            return ((SearchFolder)getSearchFolders().get(0)).folder;
+            return ((SearchFolder)getSearchFolders().get(0)).folderReference;
         }
         catch (FolderNotFoundException fnfe)
         {
         }
-        return defaultFolder;
+        return new FolderWeakReference(getView().getPageManager(), defaultFolder);
     }
 
     /**
@@ -945,10 +946,10 @@ public class FolderProxy extends NodePro
      *                                    folder with a title to use in site view at
      *                                    this proxy folder view path
      *
-     * @param defaultFolder default concrete folder
-     * @return selected concrete folder
+     * @param defaultFolder default concrete folder reference
+     * @return selected concrete folder reference
      */
-    private Folder selectTitledFromAggregateFolders(Folder defaultFolder)
+    private FolderWeakReference selectTitledFromAggregateFolders(FolderWeakReference defaultFolder)
     {
         // select most specific folder along search paths
         // with a specified title, short title, or metadata
@@ -957,7 +958,8 @@ public class FolderProxy extends NodePro
             Iterator foldersIter = getSearchFolders().iterator();
             while (foldersIter.hasNext())
             {
-                Folder folder = ((SearchFolder)foldersIter.next()).folder;
+                FolderWeakReference folderReference = ((SearchFolder)foldersIter.next()).folderReference;
+                Folder folder = folderReference.getFolder();
                 String name = folder.getName();
                 String title = folder.getTitle();
                 String shortTitle = folder.getShortTitle();
@@ -966,7 +968,7 @@ public class FolderProxy extends NodePro
                     ((shortTitle != null) && !shortTitle.equalsIgnoreCase(name)) ||
                     ((folderMetadata != null) && (folderMetadata.getFields() != null) && !folderMetadata.getFields().isEmpty()))
                 {
-                    return folder;
+                    return folderReference;
                 }
             }
         }
@@ -996,7 +998,7 @@ public class FolderProxy extends NodePro
             while (foldersIter.hasNext())
             {
                 // get folder default page name or look for fallback default name
-                Folder folder = ((SearchFolder)foldersIter.next()).folder;
+                Folder folder = ((SearchFolder)foldersIter.next()).folderReference.getFolder();
                 String defaultPageName = folder.getDefaultPage();
                 if (defaultPageName != null)
                 {
@@ -1097,7 +1099,7 @@ public class FolderProxy extends NodePro
             {
                 // aggregate folders
                 SearchFolder searchFolder = (SearchFolder)foldersIter.next();
-                Folder folder = searchFolder.folder;
+                Folder folder = searchFolder.folderReference.getFolder();
                 String locatorName = searchFolder.locatorName;
 
                 // create and save proxies for concrete children
@@ -1253,10 +1255,11 @@ public class FolderProxy extends NodePro
                 // search folders list
                 try
                 {
-                    Folder folder = getView().getPageManager().getFolder(path);
+                    PageManager pageManager = getView().getPageManager();
+                    Folder folder = pageManager.getFolder(path);
                     if (folder != null)
                     {
-                        searchFolders.add(new SearchFolder(folder, searchPath.getLocatorName()));
+                        searchFolders.add(new SearchFolder(new FolderWeakReference(pageManager, folder), searchPath.getLocatorName()));
                     }
                 }
                 catch (NodeException ne)
@@ -1313,7 +1316,7 @@ public class FolderProxy extends NodePro
                 Iterator foldersIter = searchFolders.iterator();
                 while (foldersIter.hasNext())
                 {
-                    inheritanceFolders.add(new InheritanceFolder(((SearchFolder)foldersIter.next()).folder, folder.getPath()));
+                    inheritanceFolders.add(new InheritanceFolder(((SearchFolder)foldersIter.next()).folderReference, folder.getPath()));
                 }
 
                 // get super/parent search paths

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderWeakReference.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderWeakReference.java?rev=995680&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderWeakReference.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/folder/proxy/FolderWeakReference.java Fri Sep 10 06:14:22 2010
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.jetspeed.om.folder.proxy;
+
+import java.lang.ref.WeakReference;
+
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.folder.FolderNotFoundException;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.page.document.NodeException;
+
+/**
+ * This class references PSML Folder instances weakly so that
+ * site views do not hold onto instances that would otherwise
+ * be reaped from the heap.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class FolderWeakReference
+{
+    private PageManager pageManager;
+    private String path;
+    private volatile WeakReference<Folder> referentFolder;
+    
+    /**
+     * Construct folder reference capturing page manager.
+     * 
+     * @param pageManager
+     * @param folder
+     */
+    public FolderWeakReference(PageManager pageManager, Folder folder)
+    {
+        this.pageManager = pageManager;
+        this.path = folder.getPath();
+        this.referentFolder = new WeakReference<Folder>(folder);
+    }
+    
+    /**
+     * Get or retrieve referent folder.
+     * 
+     * @return folder
+     */
+    public Folder getFolder()
+    {
+        Folder folder = referentFolder.get();
+        if ((folder != null) && !folder.isStale())
+        {
+            return folder;
+        }
+        else
+        {
+            try
+            {
+                referentFolder = new WeakReference<Folder>(pageManager.getFolder(path));
+                return referentFolder.get();
+            }
+            catch (FolderNotFoundException fnfe)
+            {
+                throw new RuntimeException("Folder "+path+" has been removed: "+fnfe, fnfe);
+            }
+            catch (NodeException ne)
+            {
+                throw new RuntimeException("Folder "+path+" can not be accessed: "+ne, ne);
+            }
+        }
+    }
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/DynamicPageProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/DynamicPageProxy.java?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/DynamicPageProxy.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/DynamicPageProxy.java Fri Sep 10 06:14:22 2010
@@ -42,9 +42,9 @@ public class DynamicPageProxy extends No
     protected static final Method GET_MENU_DEFINITIONS_METHOD = reflectMethod(DynamicPage.class, "getMenuDefinitions", null);
 
     /**
-     * dynamicPage - proxy delegate dynamic page instance
+     * dynamicPageReference - proxy delegate dynamic page instance reference
      */
-    private DynamicPage dynamicPage;
+    private DynamicPageWeakReference dynamicPageReference;
 
     /**
      * newInstance - creates a new proxy instance that implements the DynamicPage interface
@@ -72,7 +72,7 @@ public class DynamicPageProxy extends No
     private DynamicPageProxy(SearchPathsSiteView view, String locatorName, Folder parentFolder, DynamicPage dynamicPage)
     {
         super(view, locatorName, parentFolder, dynamicPage.getName(), dynamicPage.isHidden());
-        this.dynamicPage = dynamicPage;
+        this.dynamicPageReference = new DynamicPageWeakReference(view.getPageManager(), dynamicPage);
     }
     
     /**
@@ -130,7 +130,7 @@ public class DynamicPageProxy extends No
         try
         {
             // attempt to invoke method on delegate DynamicPage instance
-            return m.invoke(dynamicPage, args);
+            return m.invoke(dynamicPageReference.getDynamicPage(), args);
         }
         catch (InvocationTargetException ite)
         {
@@ -145,7 +145,7 @@ public class DynamicPageProxy extends No
      */
     public DynamicPage getDynamicPage()
     {
-        return dynamicPage;
+        return dynamicPageReference.getDynamicPage();
     }
 
     /**
@@ -160,6 +160,7 @@ public class DynamicPageProxy extends No
         // folder menu definitions include standard menu definition
         // locator defaults
         FolderProxy parentFolderProxy = FolderProxy.getFolderProxy(getParent());
+        DynamicPage dynamicPage = dynamicPageReference.getDynamicPage();
         mergeMenuDefinitionLocators(dynamicPage.getMenuDefinitions(), dynamicPage, parentFolderProxy.getPath(), true);
         mergeMenuDefinitionLocators(parentFolderProxy.getMenuDefinitionLocators());
     }

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/DynamicPageWeakReference.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/DynamicPageWeakReference.java?rev=995680&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/DynamicPageWeakReference.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/DynamicPageWeakReference.java Fri Sep 10 06:14:22 2010
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.jetspeed.om.page.proxy;
+
+import java.lang.ref.WeakReference;
+
+import org.apache.jetspeed.om.page.DynamicPage;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.page.PageNotFoundException;
+import org.apache.jetspeed.page.document.NodeException;
+
+/**
+ * This class references PSML DynamicPage instances weakly so that
+ * site views do not hold onto instances that would otherwise
+ * be reaped from the heap.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class DynamicPageWeakReference
+{
+    private PageManager pageManager;
+    private String path;
+    private volatile WeakReference<DynamicPage> referentDynamicPage;
+    
+    /**
+     * Construct dynamic page reference capturing page manager.
+     * 
+     * @param pageManager
+     * @param dynamicPage
+     */
+    public DynamicPageWeakReference(PageManager pageManager, DynamicPage dynamicPage)
+    {
+        this.pageManager = pageManager;
+        this.path = dynamicPage.getPath();
+        this.referentDynamicPage = new WeakReference<DynamicPage>(dynamicPage);
+    }
+    
+    /**
+     * Get or retrieve referent dynamic page.
+     * 
+     * @return dynamic page
+     */
+    public DynamicPage getDynamicPage()
+    {
+        DynamicPage dynamicPage = referentDynamicPage.get();
+        if ((dynamicPage != null) && !dynamicPage.isStale())
+        {
+            return dynamicPage;
+        }
+        else
+        {
+            try
+            {
+                referentDynamicPage = new WeakReference<DynamicPage>(pageManager.getDynamicPage(path));
+                return referentDynamicPage.get();
+            }
+            catch (PageNotFoundException pnfe)
+            {
+                throw new RuntimeException("DynamicPage "+path+" has been removed: "+pnfe, pnfe);
+            }
+            catch (NodeException ne)
+            {
+                throw new RuntimeException("DynamicPage "+path+" can not be accessed: "+ne, ne);
+            }
+        }
+    }
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/FragmentDefinitionProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/FragmentDefinitionProxy.java?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/FragmentDefinitionProxy.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/FragmentDefinitionProxy.java Fri Sep 10 06:14:22 2010
@@ -36,9 +36,9 @@ import org.apache.jetspeed.portalsite.vi
 public class FragmentDefinitionProxy extends NodeProxy implements InvocationHandler
 {
     /**
-     * fragmentDefinition - proxy delegate fragment definition instance
+     * fragmentDefinitionReference - proxy delegate fragment definition instance reference
      */
-    private FragmentDefinition fragmentDefinition;
+    private FragmentDefinitionWeakReference fragmentDefinitionReference;
 
     /**
      * newInstance - creates a new proxy instance that implements the FragmentDefinition interface
@@ -66,7 +66,7 @@ public class FragmentDefinitionProxy ext
     private FragmentDefinitionProxy(SearchPathsSiteView view, String locatorName, Folder parentFolder, FragmentDefinition fragmentDefinition)
     {
         super(view, locatorName, parentFolder, fragmentDefinition.getName(), false);
-        this.fragmentDefinition = fragmentDefinition;
+        this.fragmentDefinitionReference = new FragmentDefinitionWeakReference(view.getPageManager(), fragmentDefinition);
     }
     
     /**
@@ -119,7 +119,7 @@ public class FragmentDefinitionProxy ext
         try
         {
             // attempt to invoke method on delegate FragmentDefinition instance
-            return m.invoke(fragmentDefinition, args);
+            return m.invoke(fragmentDefinitionReference.getFragmentDefinition(), args);
         }
         catch (InvocationTargetException ite)
         {
@@ -134,6 +134,6 @@ public class FragmentDefinitionProxy ext
      */
     public FragmentDefinition getFragmentDefinition()
     {
-        return fragmentDefinition;
+        return fragmentDefinitionReference.getFragmentDefinition();
     }
 }

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/FragmentDefinitionWeakReference.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/FragmentDefinitionWeakReference.java?rev=995680&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/FragmentDefinitionWeakReference.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/FragmentDefinitionWeakReference.java Fri Sep 10 06:14:22 2010
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.jetspeed.om.page.proxy;
+
+import java.lang.ref.WeakReference;
+
+import org.apache.jetspeed.om.page.FragmentDefinition;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.page.PageNotFoundException;
+import org.apache.jetspeed.page.document.NodeException;
+
+/**
+ * This class references PSML FragmentDefinition instances weakly so
+ * that site views do not hold onto instances that would otherwise
+ * be reaped from the heap.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class FragmentDefinitionWeakReference
+{
+    private PageManager pageManager;
+    private String path;
+    private volatile WeakReference<FragmentDefinition> referentFragmentDefinition;
+    
+    /**
+     * Construct fragment definition reference capturing page manager.
+     * 
+     * @param pageManager
+     * @param fragmentDefinition
+     */
+    public FragmentDefinitionWeakReference(PageManager pageManager, FragmentDefinition fragmentDefinition)
+    {
+        this.pageManager = pageManager;
+        this.path = fragmentDefinition.getPath();
+        this.referentFragmentDefinition = new WeakReference<FragmentDefinition>(fragmentDefinition);
+    }
+    
+    /**
+     * Get or retrieve referent fragment definition.
+     * 
+     * @return fragment definition
+     */
+    public FragmentDefinition getFragmentDefinition()
+    {
+        FragmentDefinition fragmentDefinition = referentFragmentDefinition.get();
+        if ((fragmentDefinition != null) && !fragmentDefinition.isStale())
+        {
+            return fragmentDefinition;
+        }
+        else
+        {
+            try
+            {
+                referentFragmentDefinition = new WeakReference<FragmentDefinition>(pageManager.getFragmentDefinition(path));
+                return referentFragmentDefinition.get();
+            }
+            catch (PageNotFoundException pnfe)
+            {
+                throw new RuntimeException("FragmentDefinition "+path+" has been removed: "+pnfe, pnfe);
+            }
+            catch (NodeException ne)
+            {
+                throw new RuntimeException("FragmentDefinition "+path+" can not be accessed: "+ne, ne);
+            }
+        }
+    }
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/LinkProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/LinkProxy.java?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/LinkProxy.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/LinkProxy.java Fri Sep 10 06:14:22 2010
@@ -36,9 +36,9 @@ import org.apache.jetspeed.portalsite.vi
 public class LinkProxy extends NodeProxy implements InvocationHandler
 {
     /**
-     * link - proxy delegate link instance
+     * linkReference - proxy delegate link instance reference
      */
-    private Link link;
+    private LinkWeakReference linkReference;
 
     /**
      * newInstance - creates a new proxy instance that implements the Link interface
@@ -66,7 +66,7 @@ public class LinkProxy extends NodeProxy
     private LinkProxy(SearchPathsSiteView view, String locatorName, Folder parentFolder, Link link)
     {
         super(view, locatorName, parentFolder, link.getName(), link.isHidden());
-        this.link = link;
+        this.linkReference = new LinkWeakReference(view.getPageManager(), link);
     }
     
     /**
@@ -116,7 +116,7 @@ public class LinkProxy extends NodeProxy
         try
         {
             // attempt to invoke method on delegate Link instance
-            return m.invoke(link, args);
+            return m.invoke(linkReference.getLink(), args);
         }
         catch (InvocationTargetException ite)
         {
@@ -131,6 +131,6 @@ public class LinkProxy extends NodeProxy
      */
     public Link getLink()
     {
-        return link;
+        return linkReference.getLink();
     }
 }

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/LinkWeakReference.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/LinkWeakReference.java?rev=995680&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/LinkWeakReference.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/LinkWeakReference.java Fri Sep 10 06:14:22 2010
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.jetspeed.om.page.proxy;
+
+import java.lang.ref.WeakReference;
+
+import org.apache.jetspeed.om.page.Link;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.page.document.DocumentNotFoundException;
+import org.apache.jetspeed.page.document.NodeException;
+
+/**
+ * This class references PSML Link instances weakly so that
+ * site views do not hold onto instances that would otherwise
+ * be reaped from the heap.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class LinkWeakReference
+{
+    private PageManager pageManager;
+    private String path;
+    private volatile WeakReference<Link> referentLink;
+    
+    /**
+     * Construct link reference capturing page manager.
+     * 
+     * @param pageManager
+     * @param link
+     */
+    public LinkWeakReference(PageManager pageManager, Link link)
+    {
+        this.pageManager = pageManager;
+        this.path = link.getPath();
+        this.referentLink = new WeakReference<Link>(link);
+    }
+    
+    /**
+     * Get or retrieve referent link.
+     * 
+     * @return link
+     */
+    public Link getLink()
+    {
+        Link link = referentLink.get();
+        if ((link != null) && !link.isStale())
+        {
+            return link;
+        }
+        else
+        {
+            try
+            {
+                referentLink = new WeakReference<Link>(pageManager.getLink(path));
+                return referentLink.get();
+            }
+            catch (DocumentNotFoundException dnfe)
+            {
+                throw new RuntimeException("Link "+path+" has been removed: "+dnfe, dnfe);
+            }
+            catch (NodeException ne)
+            {
+                throw new RuntimeException("Link "+path+" can not be accessed: "+ne, ne);
+            }
+        }
+    }
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageProxy.java?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageProxy.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageProxy.java Fri Sep 10 06:14:22 2010
@@ -42,9 +42,9 @@ public class PageProxy extends NodeProxy
     protected static final Method GET_MENU_DEFINITIONS_METHOD = reflectMethod(Page.class, "getMenuDefinitions", null);
 
     /**
-     * page - proxy delegate page instance
+     * pageReference - proxy delegate page instance reference
      */
-    private Page page;
+    private PageWeakReference pageReference;
 
     /**
      * newInstance - creates a new proxy instance that implements the Page interface
@@ -72,7 +72,7 @@ public class PageProxy extends NodeProxy
     private PageProxy(SearchPathsSiteView view, String locatorName, Folder parentFolder, Page page)
     {
         super(view, locatorName, parentFolder, page.getName(), page.isHidden());
-        this.page = page;
+        this.pageReference = new PageWeakReference(view.getPageManager(), page);
     }
     
     /**
@@ -130,7 +130,7 @@ public class PageProxy extends NodeProxy
         try
         {
             // attempt to invoke method on delegate Page instance
-            return m.invoke(page, args);
+            return m.invoke(pageReference.getPage(), args);
         }
         catch (InvocationTargetException ite)
         {
@@ -145,7 +145,7 @@ public class PageProxy extends NodeProxy
      */
     public Page getPage()
     {
-        return page;
+        return pageReference.getPage();
     }
 
     /**
@@ -160,6 +160,7 @@ public class PageProxy extends NodeProxy
         // folder menu definitions include standard menu definition
         // locator defaults
         FolderProxy parentFolderProxy = FolderProxy.getFolderProxy(getParent());
+        Page page = pageReference.getPage();
         mergeMenuDefinitionLocators(page.getMenuDefinitions(), page, parentFolderProxy.getPath(), true);
         mergeMenuDefinitionLocators(parentFolderProxy.getMenuDefinitionLocators());
     }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageTemplateProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageTemplateProxy.java?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageTemplateProxy.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageTemplateProxy.java Fri Sep 10 06:14:22 2010
@@ -42,9 +42,9 @@ public class PageTemplateProxy extends N
     protected static final Method GET_MENU_DEFINITIONS_METHOD = reflectMethod(PageTemplate.class, "getMenuDefinitions", null);
 
     /**
-     * pageTemplate - proxy delegate page template instance
+     * pageTemplateReference - proxy delegate page template instance reference
      */
-    private PageTemplate pageTemplate;
+    private PageTemplateWeakReference pageTemplateReference;
 
     /**
      * newInstance - creates a new proxy instance that implements the Page interface
@@ -72,7 +72,7 @@ public class PageTemplateProxy extends N
     private PageTemplateProxy(SearchPathsSiteView view, String locatorName, Folder parentFolder, PageTemplate pageTemplate)
     {
         super(view, locatorName, parentFolder, pageTemplate.getName(), false);
-        this.pageTemplate = pageTemplate;
+        this.pageTemplateReference = new PageTemplateWeakReference(view.getPageManager(), pageTemplate);
     }
     
     /**
@@ -130,7 +130,7 @@ public class PageTemplateProxy extends N
         try
         {
             // attempt to invoke method on delegate PageTemplate instance
-            return m.invoke(pageTemplate, args);
+            return m.invoke(pageTemplateReference.getPageTemplate(), args);
         }
         catch (InvocationTargetException ite)
         {
@@ -145,7 +145,7 @@ public class PageTemplateProxy extends N
      */
     public PageTemplate getPageTemplate()
     {
-        return pageTemplate;
+        return pageTemplateReference.getPageTemplate();
     }
 
     /**
@@ -156,6 +156,7 @@ public class PageTemplateProxy extends N
     {
         // merge only page template menu definition locators by name
         FolderProxy parentFolderProxy = FolderProxy.getFolderProxy(getParent());
+        PageTemplate pageTemplate = pageTemplateReference.getPageTemplate();
         mergeMenuDefinitionLocators(pageTemplate.getMenuDefinitions(), pageTemplate, parentFolderProxy.getPath(), false);
     }
 }

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageTemplateWeakReference.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageTemplateWeakReference.java?rev=995680&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageTemplateWeakReference.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageTemplateWeakReference.java Fri Sep 10 06:14:22 2010
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.jetspeed.om.page.proxy;
+
+import java.lang.ref.WeakReference;
+
+import org.apache.jetspeed.om.page.PageTemplate;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.page.PageNotFoundException;
+import org.apache.jetspeed.page.document.NodeException;
+
+/**
+ * This class references PSML PageTemplate instances weakly so
+ * than site views do not hold onto instances that would otherwise
+ * be reaped from the heap.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class PageTemplateWeakReference
+{
+    private PageManager pageManager;
+    private String path;
+    private volatile WeakReference<PageTemplate> referentPageTemplate;
+    
+    /**
+     * Construct page template reference capturing page manager.
+     * 
+     * @param pageManager
+     * @param pageTemplate
+     */
+    public PageTemplateWeakReference(PageManager pageManager, PageTemplate pageTemplate)
+    {
+        this.pageManager = pageManager;
+        this.path = pageTemplate.getPath();
+        this.referentPageTemplate = new WeakReference<PageTemplate>(pageTemplate);
+    }
+    
+    /**
+     * Get or retrieve referent page template.
+     * 
+     * @return page template
+     */
+    public PageTemplate getPageTemplate()
+    {
+        PageTemplate pageTemplate = referentPageTemplate.get();
+        if ((pageTemplate != null) && !pageTemplate.isStale())
+        {
+            return pageTemplate;
+        }
+        else
+        {
+            try
+            {
+                referentPageTemplate = new WeakReference<PageTemplate>(pageManager.getPageTemplate(path));
+                return referentPageTemplate.get();
+            }
+            catch (PageNotFoundException pnfe)
+            {
+                throw new RuntimeException("PageTemplate "+path+" has been removed: "+pnfe, pnfe);
+            }
+            catch (NodeException ne)
+            {
+                throw new RuntimeException("PageTemplate "+path+" can not be accessed: "+ne, ne);
+            }
+        }
+    }
+}

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageWeakReference.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageWeakReference.java?rev=995680&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageWeakReference.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/om/page/proxy/PageWeakReference.java Fri Sep 10 06:14:22 2010
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.jetspeed.om.page.proxy;
+
+import java.lang.ref.WeakReference;
+
+import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.page.PageNotFoundException;
+import org.apache.jetspeed.page.document.NodeException;
+
+/**
+ * This class references PSML Page instances weakly so that
+ * site views do not hold onto instances that would otherwise
+ * be reaped from the heap.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class PageWeakReference
+{
+    private PageManager pageManager;
+    private String path;
+    private volatile WeakReference<Page> referentPage;
+    
+    /**
+     * Construct page reference capturing page manager.
+     * 
+     * @param pageManager
+     * @param page
+     */
+    public PageWeakReference(PageManager pageManager, Page page)
+    {
+        this.pageManager = pageManager;
+        this.path = page.getPath();
+        this.referentPage = new WeakReference<Page>(page);
+    }
+    
+    /**
+     * Get or retrieve referent page.
+     * 
+     * @return page
+     */
+    public Page getPage()
+    {
+        Page page = referentPage.get();
+        if ((page != null) && !page.isStale())
+        {
+            return page;
+        }
+        else
+        {
+            try
+            {
+                referentPage = new WeakReference<Page>(pageManager.getPage(path));
+                return referentPage.get();
+            }
+            catch (PageNotFoundException pnfe)
+            {
+                throw new RuntimeException("Page "+path+" has been removed: "+pnfe, pnfe);
+            }
+            catch (NodeException ne)
+            {
+                throw new RuntimeException("Page "+path+" can not be accessed: "+ne, ne);
+            }
+        }
+    }
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java Fri Sep 10 06:14:22 2010
@@ -32,7 +32,6 @@ import org.apache.jetspeed.om.folder.Fol
 import org.apache.jetspeed.om.page.BaseFragmentsElement;
 import org.apache.jetspeed.om.page.DynamicPage;
 import org.apache.jetspeed.om.page.FragmentDefinition;
-import org.apache.jetspeed.om.page.BaseConcretePageElement;
 import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.om.page.PageTemplate;
 import org.apache.jetspeed.page.PageManager;

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java Fri Sep 10 06:14:22 2010
@@ -329,7 +329,44 @@ public class PortalAdministrationImpl im
                             {
                                 innerUser.getSecurityAttributes().getAttribute(User.JETSPEED_USER_SUBSITE_ATTRIBUTE, true).setStringValue(innerUserFolderPath);
                                 userManager.updateUser(innerUser);
-                            }                                         
+                            }
+                            // ensure user folder parents are created
+                            Folder makeFolder = innerPageManager.getFolder("/");
+                            for (;;)
+                            {
+                                String path = makeFolder.getPath();
+                                if (!path.endsWith("/"))
+                                {
+                                    path += "/";
+                                }
+                                if (innerUserFolderPath.startsWith(path))
+                                {
+                                    String makeFolderName = innerUserFolderPath.substring(path.length());
+                                    int endFolderNameIndex = makeFolderName.indexOf('/');
+                                    if (endFolderNameIndex != -1)
+                                    {
+                                        makeFolderName = makeFolderName.substring(0, endFolderNameIndex);
+                                        String makeFolderPath = path+makeFolderName;
+                                        if (!innerPageManager.folderExists(makeFolderPath))
+                                        {
+                                            makeFolder = innerPageManager.newFolder(makeFolderPath);
+                                            innerPageManager.updateFolder(makeFolder);
+                                        }
+                                        else
+                                        {
+                                            makeFolder = innerPageManager.getFolder(makeFolderPath);
+                                        }
+                                    }
+                                    else
+                                    {
+                                        break;
+                                    }
+                                }
+                                else
+                                {
+                                    throw new FolderNotFoundException("Cannot make parent folders for user folder: "+innerUserFolderPath);
+                                }
+                            }
                             // create user's home folder                        
                             // deep copy from the default folder template tree, creating a deep-copy of the template
                             // in the new user's folder tree

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/BaseElement.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/BaseElement.java?rev=995680&r1=995679&r2=995680&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/BaseElement.java (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/page/BaseElement.java Fri Sep 10 06:14:22 2010
@@ -61,4 +61,15 @@ public interface BaseElement extends Sec
      * @param title the new title
      */
     void setShortTitle(String title);
+
+    /**
+     * Returns whether this object is stale and should be
+     * refreshed from the page manager. This flag need only
+     * be checked against page manager elements that are
+     * cached externally outside the scope of a single
+     * request, (e.g. cached in a session).
+     * 
+     * @return stale status flag
+     */
+    boolean isStale();
 }



---------------------------------------------------------------------
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