portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r725578 [1/3] - in /portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE: ./ components/cm/ components/cm/src/java/org/apache/jetspeed/cache/impl/ components/cm/src/test/org/apache/jetspeed/cache/ components/page-manager/ component...
Date Thu, 11 Dec 2008 05:03:11 GMT
Author: rwatler
Date: Wed Dec 10 21:03:10 2008
New Revision: 725578

URL: http://svn.apache.org/viewvc?rev=725578&view=rev
Log:
Distributed Database Page Manager EhCache Cache Backport
- backport of feature committed to 2.2 trunk
- configure via cache.xml cacheManagerConfig.defaultConfigResource bean property:
    ehcache.xml             - standalone implementation
    distributed-ehcache.xml - distributed implementation
- additional properties can also be configured using the cacheManagerConfig bean, (see EhCacheConfigResource.java)


Added:
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheConfigResource.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCacheObject.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/database-page-manager-base.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/distributed-ehcache.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/ehcache.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/log4j-stdout.properties
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/org/apache/jetspeed/page/cache/
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/org/apache/jetspeed/page/cache/DatabasePageManagerServer.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/org/apache/jetspeed/page/cache/TestDatabasePageManagerCache.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/etc/db-ojb/distributed-ehcache.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/maven-archetypes/portal/src/archetype/archetype-resources/etc/dbpsml/assembly/cache.xml
Removed:
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/tx-page-manager.xml
Modified:
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/pom.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/test/org/apache/jetspeed/cache/TestContentCache.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/test/org/apache/jetspeed/cache/TestDecorationContentCache.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/pom.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/util/interceptors/PageManagerInterceptor.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/database-page-manager.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/interceptors.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/org/apache/jetspeed/page/TestDatabasePageManager.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/org/apache/jetspeed/page/TestSecureDatabasePageManager.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/org/apache/jetspeed/page/TestSecurePermissionsDatabasePageManager.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/org/apache/jetspeed/page/TestTransactions.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/secure-database-page-manager.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/secure-permissions-database-page-manager.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/portal/pom.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/etc/db-ojb/ehcache.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/etc/import/assembly/import-page-manager.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/etc/import/build.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/etc/import/export.properties
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/etc/import/import.properties
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/installer/etc/database/build.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/installer/etc/database/import/assembly/import-page-manager.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/installer/etc/database/import/import.properties
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/jetspeed-api/src/java/org/apache/jetspeed/cache/JetspeedCache.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/jetspeed-api/src/java/org/apache/jetspeed/page/PageManager.java
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/maven-archetypes/portal/src/archetype/archetype-resources/etc/dbpsml/assembly/alternate/db-page-manager.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/maven-archetypes/portal/src/archetype/archetype-resources/etc/dbpsml/build.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/maven-archetypes/portal/src/archetype/archetype-resources/etc/dbpsml/export.properties
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/maven-archetypes/portal/src/archetype/archetype-resources/etc/dbpsml/import.properties
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/maven.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/pom.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/assembly/alternate/db-page-manager.xml
    portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/src/webapp/WEB-INF/assembly/cache.xml

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/pom.xml?rev=725578&r1=725577&r2=725578&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/pom.xml (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/pom.xml Wed Dec 10 21:03:10 2008
@@ -152,7 +152,7 @@
             <scope>runtime</scope>
         </dependency>
         <dependency>
-        	<groupId>ehcache</groupId>
+        	<groupId>net.sf.ehcache</groupId>
         	<artifactId>ehcache</artifactId>
         </dependency>
          <dependency>

Added: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheConfigResource.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheConfigResource.java?rev=725578&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheConfigResource.java (added)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheConfigResource.java Wed Dec 10 21:03:10 2008
@@ -0,0 +1,334 @@
+/*
+ * 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.cache.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.springframework.core.io.AbstractResource;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.beans.factory.InitializingBean;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * EhCacheConfigResource
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id: $
+ */
+public class EhCacheConfigResource extends AbstractResource implements InitializingBean
+{
+    protected static Log log = LogFactory.getLog(EhCacheConfigResource.class);
+    
+    // Constants
+    
+    public static final String EHCACHE_CONFIG_RESOURCE_PROP_NAME = "org.apache.jetspeed.ehcache.config.resource";
+    public static final String EHCACHE_CONFIG_RESOURCE_DEFAULT = "ehcache.xml";
+    public static final String EHCACHE_CONFIG_RESOURCE_DISTRIBUTED_CACHE = "distributed-ehcache.xml";
+
+    public static final String EHCACHE_GROUP_ADDRESS_PROP_NAME = "org.apache.jetspeed.ehcache.group.address";
+    public static final String EHCACHE_GROUP_ADDRESS_DEFAULT = "230.0.0.1";
+    public static final String EHCACHE_GROUP_PORT_PROP_NAME = "org.apache.jetspeed.ehcache.group.port";
+    public static final String EHCACHE_GROUP_PORT_DEFAULT = "4446";
+    public static final String EHCACHE_GROUP_TTL_PROP_NAME = "org.apache.jetspeed.ehcache.group.ttl";
+    public static final String EHCACHE_GROUP_TTL_DEFAULT = "1";
+    public static final String EHCACHE_GROUP_TTL_TEST_DEFAULT = "0";
+    public static final String EHCACHE_HOSTNAME_PROP_NAME = "org.apache.jetspeed.ehcache.hostname";
+    public static final String EHCACHE_HOSTNAME_DEFAULT = "";
+    public static final String EHCACHE_HOSTNAME_TEST_DEFAULT = "localhost";
+    public static final String EHCACHE_PORT_PROP_NAME = "org.apache.jetspeed.ehcache.port";
+    public static final String EHCACHE_PORT_DEFAULT = "40001";
+
+    public static final String EHCACHE_PAGE_MANAGER_MAX_ELEMENTS_LEGACY_PROP_NAME = "db.page.manager.cache.size";
+    public static final String EHCACHE_PAGE_MANAGER_MAX_ELEMENTS_PROP_NAME = "org.apache.jetspeed.ehcache.pagemanager.maxelements";
+    public static final String EHCACHE_PAGE_MANAGER_MAX_ELEMENTS_DEFAULT = "128";
+    public static final String EHCACHE_PAGE_MANAGER_ELEMENT_TTL_LEGACY_PROP_NAME = "db.page.manager.cache.expire";
+    public static final String EHCACHE_PAGE_MANAGER_ELEMENT_TTL_PROP_NAME = "org.apache.jetspeed.ehcache.pagemanager.element.ttl";
+    public static final String EHCACHE_PAGE_MANAGER_ELEMENT_TTL_DEFAULT = "150";
+
+    // Singleton implementation
+    
+    private static EhCacheConfigResource instance;
+    
+    public static EhCacheConfigResource getInstance(final String defaultConfigResource, final boolean test)
+    {
+        // construct and return a default instance
+        if ( instance == null)
+        {
+            instance = new EhCacheConfigResource();
+            instance.setDefaultConfigResource(defaultConfigResource);
+            instance.setTest(test);
+            instance.afterPropertiesSet();
+        }
+        return instance;
+    }
+    
+    // Members
+
+    private PropertiesConfiguration configuration;
+    private String defaultConfigResource;
+    private boolean test;
+    private String defaultGroupAddress;
+    private String defaultGroupPort;
+    private String defaultGroupTTL;
+    private String defaultHostname;
+    private String defaultPort;
+    private String defaultPageManagerMaxElements;
+    private String defaultPageManagerElementTTL;
+    
+    private ClassPathResource classPathResource;
+    
+    // InitializingBean implementation
+    
+    /* (non-Javadoc)
+     * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
+     */
+    public void afterPropertiesSet()
+    {
+        // copy specified configuration settings
+        if (configuration != null)
+        {
+            if (configuration.getString(EHCACHE_CONFIG_RESOURCE_PROP_NAME) != null)
+            {
+                defaultConfigResource = configuration.getString(EHCACHE_CONFIG_RESOURCE_PROP_NAME);
+            }
+            if (configuration.getString(EHCACHE_GROUP_ADDRESS_PROP_NAME) != null)
+            {
+                defaultGroupAddress = configuration.getString(EHCACHE_GROUP_ADDRESS_PROP_NAME);
+            }
+            if (configuration.getString(EHCACHE_GROUP_PORT_PROP_NAME) != null)
+            {
+                defaultGroupPort = configuration.getString(EHCACHE_GROUP_PORT_PROP_NAME);
+            }
+            if (configuration.getString(EHCACHE_GROUP_TTL_PROP_NAME) != null)
+            {
+                defaultGroupTTL = configuration.getString(EHCACHE_GROUP_TTL_PROP_NAME);
+            }
+            if (configuration.getString(EHCACHE_HOSTNAME_PROP_NAME) != null)
+            {
+                defaultHostname = configuration.getString(EHCACHE_HOSTNAME_PROP_NAME);
+            }
+            if (configuration.getString(EHCACHE_PORT_PROP_NAME) != null)
+            {
+                defaultPort = configuration.getString(EHCACHE_PORT_PROP_NAME);
+            }
+            if (configuration.getString(EHCACHE_PAGE_MANAGER_MAX_ELEMENTS_PROP_NAME) != null)
+            {
+                defaultPageManagerMaxElements = configuration.getString(EHCACHE_PAGE_MANAGER_MAX_ELEMENTS_PROP_NAME);
+            }
+            if (configuration.getString(EHCACHE_PAGE_MANAGER_ELEMENT_TTL_PROP_NAME) != null)
+            {
+                defaultPageManagerElementTTL = configuration.getString(EHCACHE_PAGE_MANAGER_ELEMENT_TTL_PROP_NAME);
+            }
+        }
+        
+        // set system properties used in global cache configuration
+        if (System.getProperty(EHCACHE_CONFIG_RESOURCE_PROP_NAME) == null)
+        {
+            System.setProperty(EHCACHE_CONFIG_RESOURCE_PROP_NAME, ((defaultConfigResource != null) ? defaultConfigResource : EHCACHE_CONFIG_RESOURCE_DEFAULT));
+        }
+        if (System.getProperty(EHCACHE_GROUP_ADDRESS_PROP_NAME) == null)
+        {
+            System.setProperty(EHCACHE_GROUP_ADDRESS_PROP_NAME, ((defaultGroupAddress != null) ? defaultGroupAddress : EHCACHE_GROUP_ADDRESS_DEFAULT));
+        }
+        if (System.getProperty(EHCACHE_GROUP_PORT_PROP_NAME) == null)
+        {
+            System.setProperty(EHCACHE_GROUP_PORT_PROP_NAME, ((defaultGroupPort != null) ? defaultGroupPort : EHCACHE_GROUP_PORT_DEFAULT));
+        }
+        if (System.getProperty(EHCACHE_GROUP_TTL_PROP_NAME) == null)
+        {
+            System.setProperty(EHCACHE_GROUP_TTL_PROP_NAME, ((defaultGroupTTL != null) ? defaultGroupTTL : (test ? EHCACHE_GROUP_TTL_TEST_DEFAULT : EHCACHE_GROUP_TTL_DEFAULT)));
+        }
+        if (System.getProperty(EHCACHE_HOSTNAME_PROP_NAME) == null)
+        {
+            System.setProperty(EHCACHE_HOSTNAME_PROP_NAME, ((defaultHostname != null) ? defaultHostname : (test ? EHCACHE_HOSTNAME_TEST_DEFAULT : EHCACHE_HOSTNAME_DEFAULT)));
+        }
+        if (System.getProperty(EHCACHE_PORT_PROP_NAME) == null)
+        {
+            System.setProperty(EHCACHE_PORT_PROP_NAME, ((defaultPort != null) ? defaultPort : EHCACHE_PORT_DEFAULT));
+        }
+        
+        // set system properties used in page manager cache configuration
+        if (System.getProperty(EHCACHE_PAGE_MANAGER_MAX_ELEMENTS_PROP_NAME) == null)
+        {
+            String pageManagerMaxElements = ((defaultPageManagerMaxElements != null) ? defaultPageManagerMaxElements : System.getProperty(EHCACHE_PAGE_MANAGER_MAX_ELEMENTS_LEGACY_PROP_NAME, EHCACHE_PAGE_MANAGER_MAX_ELEMENTS_DEFAULT));
+            if ((pageManagerMaxElements != null) && (Integer.parseInt(pageManagerMaxElements) < 0))
+            {
+                pageManagerMaxElements = EHCACHE_PAGE_MANAGER_MAX_ELEMENTS_DEFAULT;
+            }
+            System.setProperty(EHCACHE_PAGE_MANAGER_MAX_ELEMENTS_PROP_NAME, pageManagerMaxElements);
+        }
+        if (System.getProperty(EHCACHE_PAGE_MANAGER_ELEMENT_TTL_PROP_NAME) == null)
+        {
+            String pageManagerElementTTL = ((defaultPageManagerElementTTL != null) ? defaultPageManagerElementTTL : System.getProperty(EHCACHE_PAGE_MANAGER_ELEMENT_TTL_LEGACY_PROP_NAME, EHCACHE_PAGE_MANAGER_ELEMENT_TTL_DEFAULT));
+            if ((pageManagerElementTTL != null) && (Integer.parseInt(pageManagerElementTTL) < 0))
+            {
+                pageManagerElementTTL = EHCACHE_PAGE_MANAGER_ELEMENT_TTL_DEFAULT;
+            }
+            System.setProperty(EHCACHE_PAGE_MANAGER_ELEMENT_TTL_PROP_NAME, pageManagerElementTTL);
+        }
+
+        // setup delegate ClassPathResource
+        final String configResource = System.getProperty(EHCACHE_CONFIG_RESOURCE_PROP_NAME);
+        log.info("Configured with resource: "+configResource);
+        classPathResource = new ClassPathResource(configResource);
+    }
+    
+    // AbstractResource implementation
+
+    /* (non-Javadoc)
+     * @see org.springframework.core.io.AbstractResource#createRelative(java.lang.String)
+     */
+    public Resource createRelative(String relativePath) throws IOException
+    {
+        // delegate to ClassPathResource
+        return classPathResource.createRelative(relativePath);
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.core.io.AbstractResource#getFile()
+     */
+    public File getFile() throws IOException
+    {
+        // delegate to ClassPathResource
+        return classPathResource.getFile();
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.core.io.AbstractResource#getFilename()
+     */
+    public String getFilename() throws IllegalStateException
+    {
+        // delegate to ClassPathResource
+        return classPathResource.getFilename();
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.core.io.AbstractResource#getURL()
+     */
+    public URL getURL() throws IOException
+    {
+        // delegate to ClassPathResource
+        return classPathResource.getURL();
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.core.io.Resource#getDescription()
+     */
+    public String getDescription()
+    {
+        // delegate to ClassPathResource
+        return classPathResource.getDescription();
+    }
+
+    /* (non-Javadoc)
+     * @see org.springframework.core.io.InputStreamSource#getInputStream()
+     */
+    public InputStream getInputStream() throws IOException
+    {
+        // delegate to ClassPathResource
+        return classPathResource.getInputStream();
+    }
+    
+    // Data access
+        
+    /**
+     * @param configuration the configuration to set
+     */
+    public void setConfiguration(PropertiesConfiguration configuration)
+    {
+        this.configuration = configuration;
+    }
+
+    /**
+     * @param defaultConfigResource the defaultConfigResource to set
+     */
+    public void setDefaultConfigResource(String defaultConfigResource)
+    {
+        this.defaultConfigResource = defaultConfigResource;
+    }
+
+    /**
+     * @param test the test to set
+     */
+    public void setTest(boolean test)
+    {
+        this.test = test;
+    }
+
+    /**
+     * @param defaultGroupAddress the defaultGroupAddress to set
+     */
+    public void setDefaultGroupAddress(String defaultGroupAddress)
+    {
+        this.defaultGroupAddress = defaultGroupAddress;
+    }
+
+    /**
+     * @param defaultGroupPort the defaultGroupPort to set
+     */
+    public void setDefaultGroupPort(String defaultGroupPort)
+    {
+        this.defaultGroupPort = defaultGroupPort;
+    }
+
+    /**
+     * @param defaultGroupTTL the defaultGroupTTL to set
+     */
+    public void setDefaultGroupTTL(String defaultGroupTTL)
+    {
+        this.defaultGroupTTL = defaultGroupTTL;
+    }
+
+    /**
+     * @param defaultHostname the defaultHostname to set
+     */
+    public void setDefaultHostname(String defaultHostname)
+    {
+        this.defaultHostname = defaultHostname;
+    }
+
+    /**
+     * @param defaultPort the defaultPort to set
+     */
+    public void setDefaultPort(String defaultPort)
+    {
+        this.defaultPort = defaultPort;
+    }
+
+    /**
+     * @param defaultPageManagerMaxElements the defaultPageManagerMaxElements to set
+     */
+    public void setDefaultPageManagerMaxElements(String defaultPageManagerMaxElements)
+    {
+        this.defaultPageManagerMaxElements = defaultPageManagerMaxElements;
+    }
+
+    /**
+     * @param defaultPageManagerElementTTL the defaultPageManagerElementTTL to set
+     */
+    public void setDefaultPageManagerElementTTL(String defaultPageManagerElementTTL)
+    {
+        this.defaultPageManagerElementTTL = defaultPageManagerElementTTL;
+    }
+}

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java?rev=725578&r1=725577&r2=725578&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java Wed Dec 10 21:03:10 2008
@@ -17,12 +17,13 @@
 package org.apache.jetspeed.cache.impl;
 
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
-import net.sf.ehcache.Cache;
 import net.sf.ehcache.CacheException;
 import net.sf.ehcache.Ehcache;
 import net.sf.ehcache.Element;
@@ -32,13 +33,17 @@
 import org.apache.jetspeed.cache.CacheElement;
 import org.apache.jetspeed.cache.DistributedCacheObject;
 import org.apache.jetspeed.cache.JetspeedCache;
+import org.apache.jetspeed.cache.JetspeedCacheEventListener;
 import org.apache.jetspeed.request.RequestContext;
 
 public class EhCacheDistributedImpl extends EhCacheImpl implements JetspeedCache, CacheEventListener
 {
 
+    protected List localListeners = new ArrayList();
+    protected List remoteListeners = new ArrayList();
 
 	private Map refList = Collections.synchronizedMap(new HashMap());
+	private boolean removeAllLocal = false;
 
 
 	public EhCacheDistributedImpl(Ehcache ehcache)
@@ -87,6 +92,14 @@
 
 	public CacheElement createElement(Object key, Object content)
 	{
+        if (!(key instanceof Serializable))
+        {
+            throw new IllegalArgumentException("The cache key must be serializable.");
+        }
+        if (!(content instanceof DistributedCacheObject))
+        {
+            throw new IllegalArgumentException("The cache content must be a distributed cache object.");
+        }
 		return new EhCacheDistributedElementImpl((Serializable)key, (DistributedCacheObject)content);
 	}
 
@@ -122,7 +135,35 @@
 		return ehcache.removeQuiet(key);
 
 	}
+	
+    public void clear()
+    {
+        // invoke removeAll with local flag set
+        synchronized (refList)
+        {
+            removeAllLocal = true;
+            super.clear();
+            removeAllLocal = false;
+        }
+        notifyListeners(true, CacheElement.ActionRemoved,null,null);
+    }
 
+    public void addEventListener(JetspeedCacheEventListener listener, boolean local)
+    {
+        if (local)
+            localListeners.add(listener);
+        else
+            remoteListeners.add(listener);
+    }
+    
+    public void removeEventListener(JetspeedCacheEventListener listener, boolean local)
+    {
+        if (local)
+            localListeners.remove(listener);
+        else
+            remoteListeners.remove(listener);
+    }
+    
 	public void evictContentForUser(RequestContext context)
 	{
 		return;
@@ -154,6 +195,40 @@
 		}
     }
 	
+    protected void notifyListeners(boolean local, int action, Object key, Object value)
+    {
+        List listeners = (local?localListeners:remoteListeners);
+        for (int ix = 0; ix < listeners.size(); ix++)
+        {
+            try
+            {
+                JetspeedCacheEventListener listener = (JetspeedCacheEventListener)listeners.get(ix);
+                switch (action)
+                {
+                    case CacheElement.ActionAdded:
+                        listener.notifyElementAdded(this,local, key,value);
+                        break;
+                    case CacheElement.ActionChanged:
+                        listener.notifyElementChanged(this,local, key,value);
+                        break;
+                    case CacheElement.ActionRemoved:
+                        listener.notifyElementRemoved(this,local, key,value);
+                        break;
+                    case CacheElement.ActionEvicted:
+                        listener.notifyElementEvicted(this,local, key,value);
+                        break;
+                    case CacheElement.ActionExpired:
+                        listener.notifyElementExpired(this,local, key,value);
+                        break;
+                }
+            }
+            catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }       
+    }
+   
 	public void notifyElement( Ehcache cache, boolean local,Element arg1, int action)
 	{
 		if (cache != this.ehcache)
@@ -182,7 +257,7 @@
 
 	public void notifyElementEvicted(Ehcache cache, Element arg1)
 	{
-			notifyElement(cache, false, arg1,CacheElement.ActionEvicted);
+	    notifyElement(cache, false, arg1,CacheElement.ActionEvicted);
 	}
 
 	public void notifyElementExpired(Ehcache cache, Element arg1)
@@ -193,8 +268,7 @@
 	public void notifyElementPut(Ehcache cache, Element arg1)
 			throws CacheException
 	{
-		
-			notifyElement(cache, false, arg1, CacheElement.ActionAdded);
+		notifyElement(cache, false, arg1, CacheElement.ActionAdded);
 	}
 
 	public void notifyElementRemoved(Ehcache cache, Element arg1)
@@ -217,20 +291,25 @@
 		}
 		try
 		{
-			Iterator it = refList.entrySet().iterator();
-			while (it.hasNext())
-			{
-				EhCacheDistributedElementImpl e = (EhCacheDistributedElementImpl)it.next();
-				notifyListeners(false, CacheElement.ActionRemoved,e.getKey(),e);
-				e.notifyChange(CacheElement.ActionRemoved);
-			}
-			refList.clear();
-		} catch (Exception e)
+		    // synchronize on refList to ensure exclusive
+		    // operation on refList and removeAllLocal flag
+		    synchronized (refList)
+		    {
+		        // notify all listeners of element removal
+		        // and each element of its removal
+		        Iterator it = refList.values().iterator();
+		        while (it.hasNext())
+		        {
+		            EhCacheDistributedElementImpl e = (EhCacheDistributedElementImpl)it.next();
+		            notifyListeners(removeAllLocal, CacheElement.ActionRemoved,e.getKey(),e.getContent());
+		            e.notifyChange(CacheElement.ActionRemoved);
+		        }
+		        refList.clear();
+		    }
+		}
+		catch (Exception e)
 		{
 			e.printStackTrace();
 		}
-
-	
 	}
-
 }

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java?rev=725578&r1=725577&r2=725578&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java Wed Dec 10 21:03:10 2008
@@ -17,11 +17,15 @@
 package org.apache.jetspeed.cache.impl;
 
 import java.io.Serializable;
-import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
+import net.sf.ehcache.CacheException;
 import net.sf.ehcache.Ehcache;
 import net.sf.ehcache.Element;
+import net.sf.ehcache.distribution.CacheManagerPeerProvider;
+import net.sf.ehcache.event.CacheEventListener;
 
 import org.apache.jetspeed.cache.CacheElement;
 import org.apache.jetspeed.cache.ContentCacheKey;
@@ -32,12 +36,12 @@
 public class EhCacheImpl implements JetspeedCache
 {
     protected Ehcache ehcache;
-    protected List localListeners = new ArrayList();
-    protected List remoteListeners = new ArrayList();
+    protected Map cacheEventListenersMap;
     
     public EhCacheImpl(Ehcache ehcache)
     {
         this.ehcache = ehcache;
+        this.cacheEventListenersMap = new HashMap();
      }
 
     public CacheElement get(Object key)
@@ -68,14 +72,22 @@
     {
     	EhCacheElementImpl impl = (EhCacheElementImpl)element;
         ehcache.put(impl.getImplElement());
-		notifyListeners(true, CacheElement.ActionAdded,impl.getKey(),impl.getContent());
     }
     
     public CacheElement createElement(Object key, Object content)
     {
-    	if (!((key instanceof Serializable) ||  !(content instanceof Serializable)))
-    		throw new IllegalArgumentException("The cache key and the object to cache must be serializable."); //return null;
-   	    return new EhCacheElementImpl((Serializable)key, (Serializable)content);
+    	if (!(key instanceof Serializable))
+    	{
+    		throw new IllegalArgumentException("The cache key must be serializable.");
+    	}
+    	if (content instanceof Serializable)
+    	{
+            return new EhCacheElementImpl((Serializable)key, (Serializable)content);    	    
+    	}
+    	else
+    	{
+            return new EhCacheElementImpl((Serializable)key, content);
+    	}
     }
 
     public boolean remove(Object key)
@@ -84,8 +96,6 @@
         if (element == null)
             return false;
         boolean isRemoved = ehcache.remove(key);
-        if (isRemoved)
-    		notifyListeners(true, CacheElement.ActionRemoved,key,null);
         return isRemoved;
     }
     
@@ -100,7 +110,6 @@
     public void clear()
     {
         ehcache.removeAll();
-		notifyListeners(true, CacheElement.ActionRemoved,null,null);
     }
     
     public void evictContentForUser(String username)
@@ -113,22 +122,84 @@
         return;
     }
     
-    public void addEventListener(JetspeedCacheEventListener listener, boolean local)
+    public void addEventListener(final JetspeedCacheEventListener listener, final boolean local)
     {
-    	if (local)
-    		localListeners.add(listener);
-    	else
-    		remoteListeners.add(listener);
-    		
+        CacheEventListener cacheEventListener = new CacheEventListener()
+        {
+           public void notifyElementEvicted(Ehcache cache, Element element)
+           {
+               listener.notifyElementEvicted(EhCacheImpl.this, local, element.getKey(), element.getObjectValue());
+           }
+           
+           public void notifyElementExpired(Ehcache cache, Element element)
+           {
+               listener.notifyElementExpired(EhCacheImpl.this, local, element.getKey(), element.getObjectValue());
+           }
+           
+           public void notifyElementPut(Ehcache cache, Element element)
+           {
+               listener.notifyElementAdded(EhCacheImpl.this, local, element.getKey(), element.getObjectValue());
+           }
+           
+           public void notifyElementUpdated(Ehcache cache, Element element)
+           {
+               listener.notifyElementChanged(EhCacheImpl.this, local, element.getKey(), element.getObjectValue());
+           }
+           
+           public void notifyElementRemoved(Ehcache cache, Element element)
+           {
+               listener.notifyElementRemoved(EhCacheImpl.this, local, element.getKey(), ((element == null) ? null : element.getObjectValue()));
+           }
+           
+           public void notifyRemoveAll(Ehcache cache)
+           {
+               listener.notifyElementRemoved(EhCacheImpl.this, local, null, null);
+           }
+           
+           public void dispose()
+           {
+           }
+           
+           public Object clone()
+           {
+               return this;
+           }
+        };
+
+        this.cacheEventListenersMap.put(listener, cacheEventListener);
+        ehcache.getCacheEventNotificationService().registerListener(cacheEventListener);
     }
     
     public void removeEventListener(JetspeedCacheEventListener listener, boolean local)
     {
-        if (local)
-        	localListeners.remove(listener);
-        else
-        	remoteListeners.remove(listener);
-        	
+        CacheEventListener cacheEventListener = (CacheEventListener)this.cacheEventListenersMap.remove(listener);
+        
+        if (cacheEventListener != null)
+            ehcache.getCacheEventNotificationService().unregisterListener(cacheEventListener);
+    }
+    
+    public int getSize()
+    {
+        return ehcache.getSize();
+    }
+    
+    public List getKeys()
+    {
+        return ehcache.getKeys();
+    }
+    
+    public boolean isDistributed()
+    {
+        // check if cache part of a distributed cluster
+        try
+        {
+            CacheManagerPeerProvider peerProvider = ehcache.getCacheManager().getCachePeerProvider();
+            return ((peerProvider != null) && (peerProvider.listRemoteCachePeers(ehcache).size() > 0));
+        }
+        catch (CacheException ce)
+        {
+        }
+        return false;
     }
    
     // ------------------------------------------------------
@@ -142,41 +213,6 @@
     {
     }
 
-    protected void notifyListeners(boolean local, int action, Object key, Object value)
-    {
-    	List listeners = (local?localListeners:remoteListeners);
-        for (int ix = 0; ix < listeners.size(); ix++)
-        {
-        	try
-        	{
-        		JetspeedCacheEventListener listener = (JetspeedCacheEventListener)listeners.get(ix);
-        		switch (action)
-        		{
-        			case CacheElement.ActionAdded:
-        				listener.notifyElementAdded(this,local, key,value);
-        				break;
-        			case CacheElement.ActionChanged:
-        				listener.notifyElementChanged(this,local, key,value);
-        				break;
-        			case CacheElement.ActionRemoved:
-        				listener.notifyElementRemoved(this,local, key,value);
-        				break;
-        			case CacheElement.ActionEvicted:
-        				listener.notifyElementEvicted(this,local, key,value);
-        				break;
-        			case CacheElement.ActionExpired:
-        				listener.notifyElementExpired(this,local, key,value);
-        				break;
-        		}
-        	}
-        	catch (Exception e)
-        	{
-        		e.printStackTrace();
-        		
-        	}
-        }    	
-    }
-
     public ContentCacheKey createCacheKey(RequestContext rc, String windowId)
     {
         return null; // not implemented here

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/test/org/apache/jetspeed/cache/TestContentCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/test/org/apache/jetspeed/cache/TestContentCache.java?rev=725578&r1=725577&r2=725578&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/test/org/apache/jetspeed/cache/TestContentCache.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/test/org/apache/jetspeed/cache/TestContentCache.java Wed Dec 10 21:03:10 2008
@@ -28,6 +28,7 @@
 
 import org.apache.jetspeed.aggregator.PortletContent;
 import org.apache.jetspeed.aggregator.PortletRenderer;
+import org.apache.jetspeed.cache.impl.EhCacheConfigResource;
 import org.apache.jetspeed.cache.impl.EhPortletContentCacheImpl;
 import org.apache.jetspeed.cache.impl.JetspeedCacheKeyGenerator;
 import org.apache.jetspeed.mockobjects.request.MockRequestContext;
@@ -53,6 +54,7 @@
     public void testContentCacheByUser() throws Exception
     {
         // initialize ehCache
+        EhCacheConfigResource.getInstance(EhCacheConfigResource.EHCACHE_CONFIG_RESOURCE_DEFAULT, true);
         CacheManager cacheManager = new CacheManager();
         Cache ehContentCache = new Cache("ehPortletContentCache", 10000, false, false, 28800, 28800);
         cacheManager.addCache(ehContentCache);
@@ -146,6 +148,7 @@
     public void testContentCacheBySession() throws Exception
     {
         // initialize ehCache
+        EhCacheConfigResource.getInstance(EhCacheConfigResource.EHCACHE_CONFIG_RESOURCE_DEFAULT, true);
         CacheManager cacheManager = new CacheManager();
         Cache ehContentCache = new Cache("ehPortletContentCache", 10000, false, false, 28800, 28800);
         cacheManager.addCache(ehContentCache);

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/test/org/apache/jetspeed/cache/TestDecorationContentCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/test/org/apache/jetspeed/cache/TestDecorationContentCache.java?rev=725578&r1=725577&r2=725578&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/test/org/apache/jetspeed/cache/TestDecorationContentCache.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/cm/src/test/org/apache/jetspeed/cache/TestDecorationContentCache.java Wed Dec 10 21:03:10 2008
@@ -25,6 +25,7 @@
 import net.sf.ehcache.Cache;
 import net.sf.ehcache.CacheManager;
 
+import org.apache.jetspeed.cache.impl.EhCacheConfigResource;
 import org.apache.jetspeed.cache.impl.EhDecorationContentCacheImpl;
 import org.apache.jetspeed.cache.impl.JetspeedCacheKeyGenerator;
 import org.apache.jetspeed.mockobjects.request.MockRequestContext;
@@ -50,6 +51,7 @@
     public void testContentCacheByUser() throws Exception
     {
         // initialize ehCache
+        EhCacheConfigResource.getInstance(EhCacheConfigResource.EHCACHE_CONFIG_RESOURCE_DEFAULT, true);
         CacheManager cacheManager = new CacheManager();
         Cache ehContentCache = new Cache("ehDecorationContentCache", 10000, false, false, 28800, 28800);
         cacheManager.addCache(ehContentCache);
@@ -143,6 +145,7 @@
     public void testContentCacheBySession() throws Exception
     {
         // initialize ehCache
+        EhCacheConfigResource.getInstance(EhCacheConfigResource.EHCACHE_CONFIG_RESOURCE_DEFAULT, true);
         CacheManager cacheManager = new CacheManager();
         Cache ehContentCache = new Cache("ehDecorationContentCache", 10000, false, false, 28800, 28800);
         cacheManager.addCache(ehContentCache);

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/pom.xml?rev=725578&r1=725577&r2=725578&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/pom.xml (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/pom.xml Wed Dec 10 21:03:10 2008
@@ -92,6 +92,11 @@
             <artifactId>xalan</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>commons-jexl</groupId>
+            <artifactId>commons-jexl</artifactId>
+            <scope>test</scope>
+        </dependency>
 
     </dependencies>
 

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java?rev=725578&r1=725577&r2=725578&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java Wed Dec 10 21:03:10 2008
@@ -694,6 +694,14 @@
         // nothing to reset by default
     }
 
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.PageManager#isDistributed()
+     */
+    public boolean isDistributed()
+    {
+        return false;
+    }
+
     /**
      * notifyNewNode - notify page manager event listeners of
      *                 new node event

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java?rev=725578&r1=725577&r2=725578&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java Wed Dec 10 21:03:10 2008
@@ -25,6 +25,7 @@
 import javax.security.auth.Subject;
 
 import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.cache.JetspeedCache;
 import org.apache.jetspeed.components.dao.InitablePersistenceBrokerDaoSupport;
 import org.apache.jetspeed.om.common.SecurityConstraint;
 import org.apache.jetspeed.om.common.SecurityConstraints;
@@ -100,10 +101,6 @@
  */
 public class DatabasePageManager extends InitablePersistenceBrokerDaoSupport implements PageManager
 {
-    private static final int DEFAULT_CACHE_SIZE = 128;
-    private static final int MIN_CACHE_EXPIRES_SECONDS = 30;
-    private static final int DEFAULT_CACHE_EXPIRES_SECONDS = 150;
-
     private static Map modelClasses = new HashMap();
     static
     {
@@ -134,50 +131,13 @@
 
     private DelegatingPageManager delegator;
     
-    private int cacheSize;
-
-    private int cacheExpiresSeconds;
-
     private PageManager pageManagerProxy;
 
-    public DatabasePageManager(String repositoryPath, int cacheSize, int cacheExpiresSeconds, boolean isPermissionsSecurity, boolean isConstraintsSecurity)
+    public DatabasePageManager(String repositoryPath, boolean isPermissionsSecurity, boolean isConstraintsSecurity, JetspeedCache oidCache, JetspeedCache pathCache)
     {
         super(repositoryPath);
         delegator = new DelegatingPageManager(isPermissionsSecurity, isConstraintsSecurity, modelClasses);
-        this.cacheSize = Math.max(cacheSize, DEFAULT_CACHE_SIZE);
-        if (cacheExpiresSeconds < 0)
-        {
-            this.cacheExpiresSeconds = DEFAULT_CACHE_EXPIRES_SECONDS;
-        }
-        else if (cacheExpiresSeconds == 0)
-        {
-            this.cacheExpiresSeconds = 0;
-        }
-        else
-        {
-            this.cacheExpiresSeconds = Math.max(cacheExpiresSeconds, MIN_CACHE_EXPIRES_SECONDS);
-        }
-        DatabasePageManagerCache.cacheInit(this);
-    }
-
-    /**
-     * getCacheSize
-     *
-     * @return configured cache size
-     */
-    public int getCacheSize()
-    {
-        return cacheSize;
-    }
-
-    /**
-     * getCacheExpiresSeconds
-     *
-     * @return configured cache expiration in seconds
-     */
-    public int getCacheExpiresSeconds()
-    {
-        return cacheExpiresSeconds;
+        DatabasePageManagerCache.cacheInit(oidCache, pathCache, this);
     }
 
     /**
@@ -1867,5 +1827,12 @@
         }
         return pages.length;
     }
-    
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.PageManager#isDistributed()
+     */
+    public boolean isDistributed()
+    {
+        return DatabasePageManagerCache.isDistributed();
+    }
 }

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java?rev=725578&r1=725577&r2=725578&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java Wed Dec 10 21:03:10 2008
@@ -16,12 +16,15 @@
  */
 package org.apache.jetspeed.page.impl;
 
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Properties;
 
+import org.apache.jetspeed.cache.CacheElement;
+import org.apache.jetspeed.cache.JetspeedCache;
+import org.apache.jetspeed.cache.JetspeedCacheEventListener;
+import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.om.folder.impl.FolderImpl;
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.page.document.impl.NodeImpl;
@@ -37,15 +40,17 @@
  */
 public class DatabasePageManagerCache implements ObjectCache
 {
-    private static HashMap cacheByOID;
-    private static LinkedList cacheLRUList;
-    private static HashMap cacheByPath;
-    private static int cacheSize;
-    private static int cacheExpiresSeconds;
+    // Members
+    
+    private static JetspeedCache oidCache;
+    private static JetspeedCache pathCache;
     private static boolean constraintsEnabled;
     private static boolean permissionsEnabled;
     private static PageManager pageManager;
+    private static ThreadLocal transactionedOperations = new ThreadLocal();
 
+    // Implementation
+    
     /**
      * cacheInit
      *
@@ -53,27 +58,176 @@
      *
      * @param pageManager configured page manager
      */
-    public synchronized static void cacheInit(DatabasePageManager dbPageManager)
+    public synchronized static void cacheInit(final JetspeedCache oidCache, final JetspeedCache pathCache, final DatabasePageManager pageManager)
     {
-        if (pageManager == null)
+        // initialize
+        DatabasePageManagerCache.oidCache = oidCache;
+        DatabasePageManagerCache.pathCache = pathCache;
+        constraintsEnabled = pageManager.getConstraintsEnabled();
+        permissionsEnabled = pageManager.getPermissionsEnabled();
+        
+        // setup local oid cache listener
+        oidCache.addEventListener(new JetspeedCacheEventListener()
         {
-            cacheByOID = new HashMap();
-            cacheLRUList = new LinkedList();
-            cacheByPath = new HashMap();
-            cacheSize = dbPageManager.getCacheSize();
-            cacheExpiresSeconds = dbPageManager.getCacheExpiresSeconds();
-            constraintsEnabled = dbPageManager.getConstraintsEnabled();
-            permissionsEnabled = dbPageManager.getPermissionsEnabled();
-            pageManager = dbPageManager;
-        }
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementAdded(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
+             */
+            public void notifyElementAdded(final JetspeedCache cache, final boolean local, final Object key, final Object element)
+            {
+                final NodeImpl node = (NodeImpl)element;
+                // infuse node with page manager configuration
+                // or the page manager itself and add to the
+                // paths cache 
+                node.setConstraintsEnabled(constraintsEnabled);
+                node.setPermissionsEnabled(permissionsEnabled);
+                if (node instanceof FolderImpl)
+                {
+                    ((FolderImpl)node).setPageManager(pageManager);
+                }
+            }
+
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementChanged(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
+             */
+            public void notifyElementChanged(final JetspeedCache cache, final boolean local, final Object key, final Object element)
+            {
+                final NodeImpl node = (NodeImpl)element;
+                // infuse node with page manager configuration
+                // or the page manager itself and add to the
+                // paths cache 
+                node.setConstraintsEnabled(constraintsEnabled);
+                node.setPermissionsEnabled(permissionsEnabled);
+                if (node instanceof FolderImpl)
+                {
+                    ((FolderImpl)node).setPageManager(pageManager);
+                }
+            }
+
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementEvicted(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
+             */
+            public void notifyElementEvicted(final JetspeedCache cache, final boolean local, final Object key, final Object element)
+            {
+                final NodeImpl node = (NodeImpl)element;
+                // reset internal FolderImpl caches
+                if (node instanceof FolderImpl)
+                {
+                    ((FolderImpl)node).resetAll(false);
+                }
+            }
+
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementExpired(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
+             */
+            public void notifyElementExpired(final JetspeedCache cache, final boolean local, final Object key, final Object element)
+            {
+                final NodeImpl node = (NodeImpl)element;
+                // reset internal FolderImpl caches
+                if (node instanceof FolderImpl)
+                {
+                    ((FolderImpl)node).resetAll(false);
+                }
+            }
+
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementRemoved(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
+             */
+            public void notifyElementRemoved(final JetspeedCache cache, final boolean local, final Object key, final Object element)
+            {
+                final NodeImpl node = (NodeImpl)element;
+                // reset internal FolderImpl caches
+                if (node instanceof FolderImpl)
+                {
+                    ((FolderImpl)node).resetAll(false);
+                }
+            }
+        }, true);
+        
+        // setup remote path cache listener
+        pathCache.addEventListener(new JetspeedCacheEventListener()
+        {
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementAdded(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
+             */
+            public void notifyElementAdded(final JetspeedCache cache, final boolean local, final Object key, final Object element)
+            {
+            }
+
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementChanged(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
+             */
+            public void notifyElementChanged(final JetspeedCache cache, final boolean local, final Object key, final Object element)
+            {
+            }
+
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementEvicted(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
+             */
+            public void notifyElementEvicted(final JetspeedCache cache, final boolean local, final Object key, final Object element)
+            {
+            }
+
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementExpired(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
+             */
+            public void notifyElementExpired(final JetspeedCache cache, final boolean local, final Object key, final Object element)
+            {
+            }
+
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementRemoved(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
+             */
+            public void notifyElementRemoved(final JetspeedCache cache, final boolean local, final Object key, final Object element)
+            {
+                final DatabasePageManagerCacheObject cacheObject = (DatabasePageManagerCacheObject)element;
+                // remove cache object from local oid cache
+                if (cacheObject != null)
+                {
+                    final Identity oid = cacheObject.getId();
+                    final String path = cacheObject.getPath();
+                    if ((oid != null) || (path != null))
+                    {
+                        synchronized (DatabasePageManagerCache.class)
+                        {
+                            if (oid != null)
+                            {
+                                // get object cached by oid
+                                final NodeImpl node = (NodeImpl)cacheLookup(oid);
+                                // reset internal FolderImpl caches
+                                if (node instanceof FolderImpl)
+                                {
+                                    ((FolderImpl)node).resetAll(false);
+                                }
+                                // remove from cache
+                                oidCache.removeQuiet(oid);
+                            }
+                            if (path != null)
+                            {
+                                // lookup parent object cached by path and oid
+                                final int pathLastSeparatorIndex = path.lastIndexOf(Folder.PATH_SEPARATOR);
+                                final String parentPath = ((pathLastSeparatorIndex > 0) ? path.substring(0, pathLastSeparatorIndex) : Folder.PATH_SEPARATOR);
+                                final NodeImpl parentNode = cacheLookup(parentPath);
+                                // reset internal FolderImpl caches in case element removed
+                                if (parentNode instanceof FolderImpl)
+                                {
+                                    ((FolderImpl)parentNode).resetAll(false);
+                                }
+                                // remove from cache
+                                pathCache.removeQuiet(path);
+                            }
+                        }                        
+                    }
+                }
+            }
+        }, false);
     }
 
     /**
-     * setPageManagerProxy
+     * Override page manager specified during create with proxy.
      *
      * @param proxy proxied page manager interface used to
-     *              inject into Folder instances to provide
-     *              transaction/interception
+     *               inject into Folder instances to provide
+     *               transaction/intercept
      */
     public synchronized static void setPageManagerProxy(PageManager proxy)
     {
@@ -87,283 +241,211 @@
     }
 
     /**
-     * cacheLookup
-     *
-     * Lookup node instances by unique path.
+     * Lookup object instances by unique path.
      *
      * @param path node unique path
      * @return cached node
      */
-    public synchronized static NodeImpl cacheLookup(String path)
+    public synchronized static NodeImpl cacheLookup(final String path)
     {
         if (path != null)
         {
-            // return valid object cached by path
-            return (NodeImpl)cacheValidateEntry((Entry)cacheByPath.get(path));
+            // return valid object cached by path and oid
+            final CacheElement pathElement = pathCache.get(path);
+            if (pathElement != null)
+            {
+                final DatabasePageManagerCacheObject cacheObject = (DatabasePageManagerCacheObject)pathElement.getContent();
+                final NodeImpl node = (NodeImpl)cacheLookup(cacheObject.getId());
+                return node;
+            }
         }
         return null;
     }
 
     /**
-     * cacheAdd
-     *
-     * Add object to cache and cache node instances by unique path;
+     * Add object to cache and cache instances by unique path;
      * infuse nodes loaded by OJB with page manager configuration.
      *
-     * @param oid object/node indentity
+     * @param oid object/node identity
      * @param obj object/node to cache
      */
-    public synchronized static void cacheAdd(Identity oid, Object obj)
+    public synchronized static void cacheAdd(final Identity oid, final Object obj)
     {
-        Entry entry = (Entry)cacheByOID.get(oid);
-        if (entry != null)
+        if (obj instanceof NodeImpl)
         {
-            // update cache LRU order
-            cacheLRUList.remove(entry);
-            cacheLRUList.addFirst(entry);
-            // refresh cache entry
-            entry.touch();
-        }
-        else
-        {
-            // create new cache entry and map
-            entry = new Entry(obj, oid);
-            cacheByOID.put(oid, entry);
-            cacheLRUList.addFirst(entry);
-            // infuse node with page manager configuration
-            // or the page manager itself and add to the
-            // paths cache 
-            if (obj instanceof NodeImpl)
-            {
-                NodeImpl node = (NodeImpl)obj;
-                node.setConstraintsEnabled(constraintsEnabled);
-                node.setPermissionsEnabled(permissionsEnabled);
-                cacheByPath.put(node.getPath(), entry);
-                if (obj instanceof FolderImpl)
-                {
-                    ((FolderImpl)obj).setPageManager(pageManager);
-                }
-            }
-            // trim cache as required to maintain cache size
-            while (cacheLRUList.size() > cacheSize)
-            {
-                cacheRemoveEntry((Entry)cacheLRUList.getLast(), true);
-            }
+            final NodeImpl node = (NodeImpl)obj;
+            final String nodePath = node.getPath();
+
+            // add node to caches
+            oidCache.remove(oid);
+            final CacheElement element = oidCache.createElement(oid, node);
+            oidCache.put(element);
+            pathCache.remove(nodePath);
+            final CacheElement pathElement = pathCache.createElement(nodePath, new DatabasePageManagerCacheObject(oid, nodePath));
+            pathCache.put(pathElement);
         }
     }
 
     /**
-     * cacheClear
-     *
-     * Clear object and node caches.
+     * Clear object and path caches.
      */
     public synchronized static void cacheClear()
     {
-        // remove all cache entries
-        Iterator removeIter = cacheLRUList.iterator();
-        while (removeIter.hasNext())
+        // remove all items from oid cache individually
+        // to ensure notifications are run to detach
+        // elements; do not invoke oidCache.clear()
+        final Iterator removeOidIter = oidCache.getKeys().iterator();
+        while (removeOidIter.hasNext())
+        {
+            oidCache.remove((Identity)removeOidIter.next());
+        }
+        // remove all items from path cache individually
+        // to avoid potential distributed clear invocation
+        // that would be performed against all peers; do
+        // not invoke pathCache.clear()
+        final Iterator removePathIter = pathCache.getKeys().iterator();
+        while (removePathIter.hasNext())
         {
-            cacheRemoveEntry((Entry)removeIter.next(), false);
+            pathCache.removeQuiet(removePathIter.next());
         }
-        // clear cache
-        cacheByOID.clear();
-        cacheLRUList.clear();
-        cacheByPath.clear();
     }
 
     /**
-     * cacheLookup
-     *
      * Lookup objects by identity.
      *
      * @param oid object identity
      * @return cached object
      */
-    public synchronized static Object cacheLookup(Identity oid)
+    public synchronized static Object cacheLookup(final Identity oid)
     {
         if (oid != null)
         {
             // return valid object cached by oid
-            return cacheValidateEntry((Entry)cacheByOID.get(oid));
+            final CacheElement element = oidCache.get(oid);
+            if (element != null)
+            {
+                return element.getContent();
+            }
         }
         return null;
     }
 
     /**
-     * cacheRemove
-     *
-     * Remove identified object from object and node caches.
+     * Remove identified object from object and path caches.
      *
      * @param oid object identity
      */
-    public synchronized static void cacheRemove(Identity oid)
+    public synchronized static void cacheRemove(final Identity oid)
     {
         // remove from cache by oid
-        cacheRemoveEntry((Entry)cacheByOID.get(oid), true);
+        if (oid != null)
+        {
+            final NodeImpl node = (NodeImpl)cacheLookup(oid);
+            if (node != null)
+            {
+                // remove from caches
+                oidCache.remove(oid);
+                pathCache.remove(node.getPath());
+            }
+        }
     }
 
     /**
-     * cacheRemove
-     *
-     * Remove identified object from object and node caches.
+     * Remove identified object from object and path caches.
      *
      * @param path object path
      */
-    public synchronized static void cacheRemove(String path)
+    public synchronized static void cacheRemove(final String path)
     {
         // remove from cache by path
-        cacheRemoveEntry((Entry)cacheByPath.get(path), true);
+        if (path != null)
+        {
+            final CacheElement pathElement = pathCache.get(path);
+            if (pathElement != null)
+            {
+                final DatabasePageManagerCacheObject cacheObject = (DatabasePageManagerCacheObject)pathElement.getContent();
+                // remove from caches
+                oidCache.remove(cacheObject.getId());
+                pathCache.remove(path);
+            }
+        }
     }
     
     /**
-     * cacheValidateEntry
-     *
-     * Validate specified entry from cache, returning cached
-     * object if valid.
-     *
-     * @param entry cache entry to validate
-     * @return validated object from cache
+     * Reset cached security constraints in all cached objects.
      */
-    private synchronized static Object cacheValidateEntry(Entry entry)
+    public synchronized static void resetCachedSecurityConstraints()
     {
-        if (entry != null)
+        // reset cached objects
+        final Iterator resetIter = oidCache.getKeys().iterator();
+        while (resetIter.hasNext())
         {
-            if (!entry.isExpired())
-            {
-                // update cache LRU order
-                cacheLRUList.remove(entry);
-                cacheLRUList.addFirst(entry);
-                // refresh cache entry and return object
-                entry.touch();
-                return entry.getObject();
-            }
-            else
-            {
-                // remove expired entry
-                cacheRemoveEntry(entry, true);
-            }
+            final NodeImpl node = (NodeImpl)cacheLookup((Identity)resetIter.next());
+            node.resetCachedSecurityConstraints();
         }
-        return null;
     }
     
     /**
-     * cacheRemoveEntry
-     *
-     * Remove specified entry from cache.
-     *
-     * @param entry cache entry to remove
-     * @param remove enable removal from cache
+     * Get transactions registered on current thread
+     * 
+     * @return transactions list
      */
-    private synchronized static void cacheRemoveEntry(Entry entry, boolean remove)
+    public static List getTransactions()
     {
-        if (entry != null)
+        List operations = (List)transactionedOperations.get();
+        if (operations == null)
         {
-            Object removeObj = entry.getObject();
-            if (remove)
-            {
-                // remove entry, optimize for removal from end
-                // of list as cache size is met or entries expire
-                if (cacheLRUList.getLast() == entry)
-                {
-                    cacheLRUList.removeLast();
-                }
-                else
-                {
-                    int removeIndex = cacheLRUList.lastIndexOf(entry);
-                    if (removeIndex > 0)
-                    {
-                        cacheLRUList.remove(removeIndex);
-                    }
-                }
-                // unmap entry
-                cacheByOID.remove(entry.getOID());
-                if (removeObj instanceof NodeImpl)
-                {
-                    cacheByPath.remove(((NodeImpl)removeObj).getPath());
-                }
-            }
-            // reset internal FolderImpl caches
-            if (removeObj instanceof FolderImpl)
-            {
-                ((FolderImpl)removeObj).resetAll(false);
-            }
+            operations = new LinkedList();
+            transactionedOperations.set(operations);
         }
+        return operations;
     }
 
     /**
-     * resetCachedSecurityConstraints
-     *
-     * Reset cached security constraints in all cached node objects.
+     * Register transactions with current thread
+     * 
+     * @param operation transaction operation
      */
-    public synchronized static void resetCachedSecurityConstraints()
+    public static void addTransaction(TransactionedOperation operation)
     {
-        // reset cached objects
-        Iterator resetIter = cacheLRUList.iterator();
-        while (resetIter.hasNext())
-        {
-            Object obj = ((Entry)resetIter.next()).getObject();
-            if (obj instanceof NodeImpl)
-            {
-                ((NodeImpl)obj).resetCachedSecurityConstraints();
-            }
-        }
+        final List transactions = getTransactions();        
+        transactions.add(operation);
     }
-
+    
     /**
-     * Entry
-     *
-     * Cache entry class adding entry timestamp to track expiration
+     * Rollback transactions registered with current thread.
      */
-    private static class Entry
+    public synchronized static void rollbackTransactions()
     {
-        public long timestamp;
-        public Object object;
-        public Identity oid;
-
-        public Entry(Object object, Identity oid)
-        {
-            touch();
-            this.object = object;
-            this.oid = oid;
-        }
-
-        public boolean isExpired()
-        {
-            if (DatabasePageManagerCache.cacheExpiresSeconds > 0)
-            {
-                long now = System.currentTimeMillis();
-                if (((now - timestamp) / 1000) < DatabasePageManagerCache.cacheExpiresSeconds)
-                {
-                    timestamp = now;
-                    return false;
-                }
-                return true;
-            }
-            return false;
-        }
-        
-        public void touch()
+        final Iterator transactions = getTransactions().iterator();
+        while (transactions.hasNext())
         {
-            if (DatabasePageManagerCache.cacheExpiresSeconds > 0)
-            {
-                timestamp = System.currentTimeMillis();
-            }
+            final TransactionedOperation operation = (TransactionedOperation)transactions.next();
+            cacheRemove(operation.getPath());
         }
+    }
 
-        public Object getObject()
-        {
-            return object;
-        }
+    /**
+     * Clear transactions registered with current thread.
+     */
+    public synchronized static void clearTransactions()
+    {
+        transactionedOperations.set(null);
+    }
 
-        public Identity getOID()
-        {
-            return oid;
-        }
+    /**
+     * Returns whether this cache is currently part of a distributed cache cluster.
+     * 
+     * @return distributed flag
+     */
+    public static boolean isDistributed()
+    {
+        return pathCache.isDistributed();
     }
 
+    // OJB Constructor
+    
     /**
-     * DatabasePageManagerCache
-     *
      * Construct a cache instance using OJB compliant signatures.
      *
      * @param broker broker that is to own cache
@@ -373,6 +455,8 @@
     {
     }
 
+    // OJB ObjectCache Implementation
+    
     /* (non-Javadoc)
      * @see org.apache.ojb.broker.cache.ObjectCache#cache(org.apache.ojb.broker.Identity, java.lang.Object)
      */
@@ -405,57 +489,21 @@
         cacheRemove(oid);
     }
 
-    public synchronized static void dump()
-    {
-        System.out.println("--------------------------1");        
-        Iterator dumpIter = cacheLRUList.iterator();
-        while (dumpIter.hasNext())
-        {
-            Entry entry = (Entry)dumpIter.next();
-            Object entryObject = entry.getObject();
-            if (entryObject instanceof NodeImpl)
-            {
-                System.out.println("entry = " + ((NodeImpl)entryObject).getPath() + ", " + entry.getOID());
-            }
-            else
-            {
-                System.out.println("entry = <none>, " + entry.getOID());
-            }
-        }
-        System.out.println("--------------------------2");
-    }
-    
-    protected static ThreadLocal transactionedOperations = new ThreadLocal();
+    // Utilities
     
-    public static List getTransactions()
-    {
-        List operations = (List)transactionedOperations.get();
-        if (operations == null)
-        {
-            operations = new LinkedList();
-            transactionedOperations.set(operations);
-        }
-        
-        return operations;
-    }
-
     /**
-     * @param principal
-     *            The principal to set.
+     * Dump cache paths and oids to standard out.
      */
-    public static void addTransaction(TransactionedOperation operation)
-    {
-        List transactions = getTransactions();        
-        transactions.add(operation);
-    }
-    
-    public static void rollbackTransactions()
+    public synchronized static void dump()
     {
-        Iterator transactions = getTransactions().iterator();
-        while (transactions.hasNext())
+        System.out.println("--------------------------");        
+        final Iterator dumpIter = oidCache.getKeys().iterator();
+        while (dumpIter.hasNext())
         {
-            TransactionedOperation operation = (TransactionedOperation)transactions.next();
-            cacheRemove(operation.getPath());
+            final Identity oid = (Identity)dumpIter.next();
+            final NodeImpl node = (NodeImpl)cacheLookup(oid);
+            System.out.println("node="+node.getPath()+", oid="+oid);
         }
-    }
+        System.out.println("--------------------------");
+    }    
 }

Added: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCacheObject.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCacheObject.java?rev=725578&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCacheObject.java (added)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCacheObject.java Wed Dec 10 21:03:10 2008
@@ -0,0 +1,118 @@
+/*
+ * 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.page.impl;
+
+import org.apache.jetspeed.cache.CacheElement;
+import org.apache.jetspeed.cache.DistributedCacheObject;
+import org.apache.ojb.broker.Identity;
+
+/**
+ * DatabasePageManagerCacheObject
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id: $
+*/
+public class DatabasePageManagerCacheObject implements DistributedCacheObject
+{
+    private static final long serialVersionUID = 3575475610695136850L;
+
+    // Members
+    
+    private Identity id = null;
+    private String path = null;
+
+    // Constructor
+    
+    /**
+     * Construct new cache object with id and path
+     * 
+     * @param id
+     * @param path
+     */
+    public DatabasePageManagerCacheObject(final Identity id, final String path)
+    {
+        this.path = path;
+        this.id = id;
+    }
+
+    /**
+     * Serialization constructor
+     */
+    public DatabasePageManagerCacheObject()
+    {
+    }
+
+    // Implementation
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.cache.DistributedCacheObject#notifyChange(int)
+     */
+    public void notifyChange(int action)
+    {
+        switch (action)
+        {
+            case CacheElement.ActionAdded:
+            case CacheElement.ActionChanged:
+            case CacheElement.ActionRemoved:
+            case CacheElement.ActionEvicted:
+            case CacheElement.ActionExpired:
+                break;
+            default:
+                return;
+        }
+        return;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object obj)
+    {
+        if ((obj != null) && (obj instanceof DatabasePageManagerCacheObject))
+        {
+            final DatabasePageManagerCacheObject other = (DatabasePageManagerCacheObject) obj;
+            return getPath().equals(other.getPath());
+        }
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode()
+    {
+        return getPath().hashCode();
+    }
+
+    // Data access
+    
+    /**
+     * @return wrapper id
+     */
+    public Identity getId()
+    {
+        return id;
+    }
+
+    /**
+     * @return wrapper path
+     */
+    public String getPath()
+    {
+        return path;
+    }
+}

Modified: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/util/interceptors/PageManagerInterceptor.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/util/interceptors/PageManagerInterceptor.java?rev=725578&r1=725577&r2=725578&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/util/interceptors/PageManagerInterceptor.java (original)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/java/org/apache/jetspeed/util/interceptors/PageManagerInterceptor.java Wed Dec 10 21:03:10 2008
@@ -46,6 +46,10 @@
             DatabasePageManagerCache.rollbackTransactions();
             throw exp;
         }
+        finally
+        {
+            DatabasePageManagerCache.clearTransactions();            
+        }
     }
 
 }

Added: portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/database-page-manager-base.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/database-page-manager-base.xml?rev=725578&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/database-page-manager-base.xml (added)
+++ portals/jetspeed-2/portal/branches/JETSPEED-2.1.3-POSTRELEASE/components/page-manager/src/test/database-page-manager-base.xml Wed Dec 10 21:03:10 2008
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+    <!-- Page Manager Caches -->
+    <bean id="cacheManagerConfig" class="org.apache.jetspeed.cache.impl.EhCacheConfigResource">
+        <property name="defaultConfigResource" value="ehcache.xml"/>
+        <property name="test" value="true"/>
+    </bean>
+
+    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
+        <property name="configLocation" ref="cacheManagerConfig"/>
+    </bean>
+
+    <bean id="ehPageManagerOidCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <property name="cacheManager" ref="cacheManager"/>
+        <property name="cacheName" value="pageManagerOidCache"/>
+    </bean>
+    
+    <bean id="ehPageManagerPathCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+        <property name="cacheManager" ref="cacheManager"/>
+        <property name="cacheName" value="pageManagerPathCache"/>
+    </bean>
+    
+    <bean id="pageManagerOidCache" class="org.apache.jetspeed.cache.impl.EhCacheImpl">
+        <constructor-arg><ref bean="ehPageManagerOidCache"/></constructor-arg>
+    </bean>
+    
+    <bean id="pageManagerPathCache" class="org.apache.jetspeed.cache.impl.EhCacheDistributedImpl">
+        <constructor-arg><ref bean="ehPageManagerPathCache"/></constructor-arg>
+    </bean>
+    
+    <!-- Transaction Proxying -->
+    <bean id="pageManagerInterceptor" class="org.apache.jetspeed.util.interceptors.PageManagerInterceptor">
+    </bean>
+
+    <bean id="pageManager" parent="baseTransactionProxy">
+        <property name="proxyInterfaces">
+            <value>org.apache.jetspeed.page.PageManager</value>
+        </property>
+        <property name="target">
+            <ref bean="pageManagerImpl" />
+        </property>
+        <property name="transactionAttributes">
+            <props>
+              <prop key="getPage*">PROPAGATION_SUPPORTS</prop>  
+              <prop key="getLink*">PROPAGATION_SUPPORTS</prop>  
+              <prop key="getFolder*">PROPAGATION_SUPPORTS</prop>  
+              <prop key="getContentPage">PROPAGATION_SUPPORTS</prop>  
+              <prop key="getAll">PROPAGATION_SUPPORTS</prop>  
+              <prop key="getUserFolder">PROPAGATION_SUPPORTS</prop>  
+              <prop key="update*">PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException</prop>
+              <prop key="removePage">PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException</prop>
+              <prop key="removeFolder">PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException</prop>
+              <prop key="removeLink">PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException</prop>
+              <prop key="removePageSecurity">PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException</prop>                            
+              <prop key="createUserHomePagesFromRoles">PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException</prop>
+              <prop key="deepCopy*">PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException</prop>
+              <prop key="addPages">PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException</prop>              
+              <prop key="folderExists">PROPAGATION_SUPPORTS</prop>  
+              <prop key="pageExists">PROPAGATION_SUPPORTS</prop>  
+              <prop key="linkExists">PROPAGATION_SUPPORTS</prop>  
+              <prop key="userFolderExists">PROPAGATION_SUPPORTS</prop>  
+              <prop key="userPageExists">PROPAGATION_SUPPORTS</prop>  
+            </props>
+        </property>
+        <property name="preInterceptors"> 
+            <list>
+                <ref bean="pageManagerInterceptor" />
+            </list>
+        </property>
+    </bean>
+
+    <!-- Inject Page Manager Proxy into Page Manager -->
+    <bean id="injectPageManagerProxy" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+        <property name="targetObject"><ref bean="pageManagerImpl"/></property>
+        <property name="targetMethod"><value>setPageManagerProxy</value></property>
+        <property name="arguments">
+            <list>
+                <ref bean="pageManager"/>
+            </list>
+        </property>
+    </bean>
+
+</beans>



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