From svnnotify @ sourceforge.jp Wed Mar 4 12:07:50 2009
From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp)
Date: Wed, 04 Mar 2009 12:07:50 +0900
Subject: [pal-cvs 4050] [1785] applied patch 'r725578: Distributed Database
Page Manager EhCache Cache Backport'
Message-ID: <1236136070.709423.31363.nullmailer@users.sourceforge.jp>
Revision: 1785
http://svn.sourceforge.jp/view?root=pal&view=rev&rev=1785
Author: sone
Date: 2009-03-04 12:07:50 +0900 (Wed, 04 Mar 2009)
Log Message:
-----------
applied patch 'r725578: Distributed Database Page Manager EhCache Cache Backport'
Modified Paths:
--------------
pal-portal/branches/pal-portal-1.x/installer/etc/database/build.xml
pal-portal/branches/pal-portal-1.x/installer/etc/database/import/assembly/import-page-manager.xml
pal-portal/branches/pal-portal-1.x/installer/etc/database/import/import.properties
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/.classpath
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/test/org/apache/jetspeed/cache/TestContentCache.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/test/org/apache/jetspeed/cache/TestDecorationContentCache.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/project.xml
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/util/interceptors/PageManagerInterceptor.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/database-page-manager.xml
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/interceptors.xml
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/TestTransactions.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/secure-database-page-manager.xml
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/secure-permissions-database-page-manager.xml
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/db-ojb/ehcache.xml
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/import/assembly/import-page-manager.xml
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/import/build.xml
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/import/export.properties
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/import/import.properties
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/cache/JetspeedCache.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/page/PageManager.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/maven.xml
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/alternate/db-page-manager.xml
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/cache.xml
Added Paths:
-----------
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheConfigResource.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCacheObject.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/database-page-manager-base.xml
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/distributed-ehcache.xml
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/ehcache.xml
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/log4j-stdout.properties
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/cache/
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/cache/DatabasePageManagerServer.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/cache/TestDatabasePageManagerCache.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/db-ojb/distributed-ehcache.xml
Removed Paths:
-------------
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/tx-page-manager.xml
-------------- next part --------------
Modified: pal-portal/branches/pal-portal-1.x/installer/etc/database/build.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/installer/etc/database/build.xml 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/installer/etc/database/build.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -343,6 +343,7 @@
+
Modified: pal-portal/branches/pal-portal-1.x/installer/etc/database/import/assembly/import-page-manager.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/installer/etc/database/import/assembly/import-page-manager.xml 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/installer/etc/database/import/assembly/import-page-manager.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -44,14 +44,14 @@
class="org.apache.jetspeed.page.impl.DatabasePageManager">
JETSPEED-INF/ojb/page-manager-repository.xml
-
- 128
-
- 0
- false
+ false
- false
+ false
+
+
+
+
Modified: pal-portal/branches/pal-portal-1.x/installer/etc/database/import/import.properties
===================================================================
--- pal-portal/branches/pal-portal-1.x/installer/etc/database/import/import.properties 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/installer/etc/database/import/import.properties 2009-03-04 03:07:50 UTC (rev 1785)
@@ -1,7 +1,7 @@
# comma-separated list of boot assemblies for Spring
boot.assemblies = repository-datasource-spring.xml
# comma-separated list of assemblies for Spring
-assemblies = import-page-manager.xml, transaction.xml, interceptors.xml
+assemblies = import-page-manager.xml, transaction.xml, interceptors.xml, cache.xml
# root folder to start exporting from
root.folder = /
# overwrite folders flag, set to true to replace existing folders
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/.classpath
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/.classpath 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/.classpath 2009-03-04 03:07:50 UTC (rev 1785)
@@ -108,5 +108,6 @@
+
Added: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheConfigResource.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheConfigResource.java (rev 0)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheConfigResource.java 2009-03-04 03:07:50 UTC (rev 1785)
@@ -0,0 +1,400 @@
+/*
+ * 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.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.core.io.AbstractResource;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+/**
+ * EhCacheConfigResource
+ *
+ * @author Randy Watler
+ * @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: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java 2009-03-04 03:07:50 UTC (rev 1785)
@@ -51,6 +51,8 @@
private Map refList = Collections.synchronizedMap(new HashMap());
+ private boolean removeAllLocal = false;
+
public EhCacheDistributedImpl(Ehcache ehcache)
{
super(ehcache);
@@ -94,6 +96,11 @@
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);
}
@@ -131,7 +138,13 @@
public void clear()
{
- super.clear();
+ // invoke removeAll with local flag set
+ synchronized (refList)
+ {
+ removeAllLocal = true;
+ super.clear();
+ removeAllLocal = false;
+ }
notifyListeners(true, CacheElement.ActionRemoved, null, null);
}
@@ -306,16 +319,23 @@
}
try
{
- Iterator it = refList.entrySet().iterator();
- while (it.hasNext())
+ // synchronize on refList to ensure exclusive
+ // operation on refList and removeAllLocal flag
+ synchronized (refList)
{
- EhCacheDistributedElementImpl e = (EhCacheDistributedElementImpl) it
- .next();
- notifyListeners(false, CacheElement.ActionRemoved, e.getKey(),
- e);
- e.notifyChange(CacheElement.ActionRemoved);
+ // 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();
}
- refList.clear();
}
catch (Exception e)
{
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java 2009-03-04 03:07:50 UTC (rev 1785)
@@ -23,8 +23,10 @@
import jp.sf.pal.portal.logging.Log;
import jp.sf.pal.portal.logging.LogFactory;
+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;
@@ -78,12 +80,17 @@
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)
@@ -194,6 +201,22 @@
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;
+ }
+
// ------------------------------------------------------
public Object clone() throws CloneNotSupportedException
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/test/org/apache/jetspeed/cache/TestContentCache.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/test/org/apache/jetspeed/cache/TestContentCache.java 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/test/org/apache/jetspeed/cache/TestContentCache.java 2009-03-04 03:07:50 UTC (rev 1785)
@@ -26,6 +26,7 @@
import net.sf.ehcache.CacheManager;
import org.apache.jetspeed.aggregator.PortletContent;
+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;
@@ -52,6 +53,8 @@
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);
@@ -151,6 +154,8 @@
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);
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/test/org/apache/jetspeed/cache/TestDecorationContentCache.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/test/org/apache/jetspeed/cache/TestDecorationContentCache.java 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/cm/src/test/org/apache/jetspeed/cache/TestDecorationContentCache.java 2009-03-04 03:07:50 UTC (rev 1785)
@@ -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;
@@ -51,6 +52,8 @@
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);
@@ -146,6 +149,8 @@
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);
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/project.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/project.xml 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/project.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -80,6 +80,11 @@
org.apache.portals.jetspeed-2:jetspeed-rdbms${jetspeed.version}
+
+ commons-jexl
+ commons-jexl
+ 1.1
+
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java 2009-03-04 03:07:50 UTC (rev 1785)
@@ -881,6 +881,14 @@
// nothing to shutdown 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: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java 2009-03-04 03:07:50 UTC (rev 1785)
@@ -28,6 +28,7 @@
import jp.sf.pal.portal.logging.LogFactory;
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;
@@ -105,12 +106,6 @@
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
{
@@ -159,60 +154,22 @@
private DelegatingPageManager delegator;
- private int cacheSize;
-
- private int cacheExpiresSeconds;
-
private PageManager pageManagerProxy;
protected static final Log log = LogFactory
.getLog(DatabasePageManager.class);
- 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);
+ DatabasePageManagerCache.cacheInit(oidCache, pathCache, this);
}
/**
- * getCacheSize
- *
- * @return configured cache size
- */
- public int getCacheSize()
- {
- return cacheSize;
- }
-
- /**
- * getCacheExpiresSeconds
- *
- * @return configured cache expiration in seconds
- */
- public int getCacheExpiresSeconds()
- {
- return cacheExpiresSeconds;
- }
-
- /**
* getPageManagerProxy
*
* @return proxied page manager interface used to inject into Folder
@@ -2246,4 +2203,11 @@
return pages.length;
}
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.page.PageManager#isDistributed()
+ */
+ public boolean isDistributed()
+ {
+ return DatabasePageManagerCache.isDistributed();
+ }
}
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCache.java 2009-03-04 03:07:50 UTC (rev 1785)
@@ -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;
@@ -38,22 +41,22 @@
public class DatabasePageManagerCache implements ObjectCache
{
- private static HashMap cacheByOID;
+ // Members
- private static LinkedList cacheLRUList;
+ private static JetspeedCache oidCache;
- private static HashMap cacheByPath;
+ private static JetspeedCache pathCache;
- private static int cacheSize;
-
- private static int cacheExpiresSeconds;
-
private static boolean constraintsEnabled;
private static boolean permissionsEnabled;
private static PageManager pageManager;
+ private static ThreadLocal transactionedOperations = new ThreadLocal();
+
+ // Implementation
+
/**
* cacheInit
*
@@ -62,24 +65,189 @@
* @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()
{
- cacheClear();
- }
- 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
@@ -99,293 +267,225 @@
/**
* 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; infuse nodes
+ * Add object to cache and cache instances by unique path;
* loaded by OJB with page manager configuration.
*
* @param oid
- * object/node indentity
+ * 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();
+ 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);
}
- 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);
- }
- }
}
/**
* 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())
{
- cacheRemoveEntry((Entry) removeIter.next(), false);
+ oidCache.remove((Identity) removeOidIter.next());
}
- // clear cache
- cacheByOID.clear();
- cacheLRUList.clear();
- cacheByPath.clear();
+ // 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())
+ {
+ pathCache.removeQuiet(removePathIter.next());
+ }
}
/**
- * 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 path caches.
*
- * Remove identified object from object and node 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 path caches.
*
- * Remove identified object from object and node 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
+ * Get transactions registered on current thread
*
- * Remove specified entry from cache.
- *
- * @param entry
- * cache entry to remove
- * @param remove
- * enable removal from cache
+ * @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
+ * Register transactions with current thread
*
- * Reset cached security constraints in all cached node objects.
+ * @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)
+ final Iterator transactions = getTransactions().iterator();
+ while (transactions.hasNext())
{
- touch();
- this.object = object;
- this.oid = oid;
+ final TransactionedOperation operation = (TransactionedOperation) transactions
+ .next();
+ cacheRemove(operation.getPath());
}
+ }
- 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;
- }
+ /**
+ * Clear transactions registered with current thread.
+ */
+ public synchronized static void clearTransactions()
+ {
+ transactionedOperations.set(null);
+ }
- public void touch()
- {
- if (DatabasePageManagerCache.cacheExpiresSeconds > 0)
- {
- timestamp = System.currentTimeMillis();
- }
- }
+ /**
+ * Returns whether this cache is currently part of a distributed cache cluster.
+ *
+ * @return distributed flag
+ */
+ public static boolean isDistributed()
+ {
+ return pathCache.isDistributed();
+ }
- public Object getObject()
- {
- return object;
- }
+ // OJB Constructor
- public Identity getOID()
- {
- return oid;
- }
- }
-
/**
- * DatabasePageManagerCache
- *
* Construct a cache instance using OJB compliant signatures.
*
* @param broker
@@ -397,6 +497,8 @@
{
}
+ // OJB ObjectCache Implementation
+
/*
* (non-Javadoc)
*
@@ -443,61 +545,24 @@
cacheRemove(oid);
}
+ // Utilities
+
+ /**
+ * Dump cache paths and oids to standard out.
+ */
+
public synchronized static void dump()
{
- System.out.println("--------------------------1");
- Iterator dumpIter = cacheLRUList.iterator();
+ System.out.println("--------------------------");
+ final Iterator dumpIter = oidCache.getKeys().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 = , " + entry.getOID());
- }
+ final Identity oid = (Identity) dumpIter.next();
+ final NodeImpl node = (NodeImpl) cacheLookup(oid);
+ System.out.println("node=" + node.getPath() + ", oid=" + oid);
}
- System.out.println("--------------------------2");
- }
- // TODO Findbugs
- protected static ThreadLocal transactionedOperations = new ThreadLocal();
-
- public static List getTransactions()
- {
- List operations = (List) transactionedOperations.get();
- if (operations == null)
- {
- operations = new LinkedList();
- transactionedOperations.set(operations);
- }
-
- return operations;
+ System.out.println("--------------------------");
}
- /**
- * @param principal
- * The principal to set.
- */
- public static void addTransaction(TransactionedOperation operation)
- {
- List transactions = getTransactions();
- transactions.add(operation);
- }
-
- public static void rollbackTransactions()
- {
- Iterator transactions = getTransactions().iterator();
- while (transactions.hasNext())
- {
- TransactionedOperation operation = (TransactionedOperation) transactions
- .next();
- cacheRemove(operation.getPath());
- }
- }
}
Added: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCacheObject.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCacheObject.java (rev 0)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManagerCacheObject.java 2009-03-04 03:07:50 UTC (rev 1785)
@@ -0,0 +1,120 @@
+/*
+ * 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 Randy Watler
+ * @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: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/util/interceptors/PageManagerInterceptor.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/util/interceptors/PageManagerInterceptor.java 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/util/interceptors/PageManagerInterceptor.java 2009-03-04 03:07:50 UTC (rev 1785)
@@ -46,6 +46,11 @@
DatabasePageManagerCache.rollbackTransactions();
throw exp;
}
+ finally
+ {
+ DatabasePageManagerCache.clearTransactions();
+ }
+
}
}
Added: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/database-page-manager-base.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/database-page-manager-base.xml (rev 0)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/database-page-manager-base.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -0,0 +1,102 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.jetspeed.page.PageManager
+
+
+
+
+
+
+ PROPAGATION_SUPPORTS
+ PROPAGATION_SUPPORTS
+ PROPAGATION_SUPPORTS
+ PROPAGATION_SUPPORTS
+ PROPAGATION_SUPPORTS
+ PROPAGATION_SUPPORTS
+ PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
+ PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
+ PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
+ PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
+ PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
+ PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
+ PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
+ PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
+ PROPAGATION_SUPPORTS
+ PROPAGATION_SUPPORTS
+ PROPAGATION_SUPPORTS
+ PROPAGATION_SUPPORTS
+ PROPAGATION_SUPPORTS
+
+
+
+
+
+
+
+
+
+
+
+
+ setPageManagerProxy
+
+
+
+
+
+
+
+
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/database-page-manager.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/database-page-manager.xml 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/database-page-manager.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -18,65 +18,20 @@
-->
+
+
-
+
- JETSPEED-INF/ojb/page-manager-repository.xml
-
- 128
-
- 0
+ JETSPEED-INF/ojb/page-manager-repository.xml
- false
+ false
- false
+ false
+
+
+
+
-
-
-
- org.apache.jetspeed.page.PageManager
-
-
-
-
-
-
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
-
-
-
-
-
-
-
- setPageManagerProxy
-
-
-
-
-
-
-
Added: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/distributed-ehcache.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/distributed-ehcache.xml (rev 0)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/distributed-ehcache.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Added: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/ehcache.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/ehcache.xml (rev 0)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/ehcache.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/interceptors.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/interceptors.xml 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/interceptors.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -16,35 +16,14 @@
limitations under the License.
-->
-
+
+
-
-
-
-
-
-
-
-
- PROPAGATION_REQUIRED
-
-
-
-
-
-
-
-
-
-
-
+ -->
+
Added: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/log4j-stdout.properties
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/log4j-stdout.properties (rev 0)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/log4j-stdout.properties 2009-03-04 03:07:50 UTC (rev 1785)
@@ -0,0 +1,31 @@
+# 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.
+
+# ------------------------------------------------------------------------
+#
+# Stdout Logging Configuration
+#
+# $Id: log4j.properties 722139 2008-12-01 17:22:03Z rwatler $
+#
+# ------------------------------------------------------------------------
+
+log4j.rootLogger = ERROR, stdout
+
+log4j.category.org.apache.jetspeed = INFO, stdout
+log4j.additivity.org.apache.jetspeed = false
+
+log4j.appender.stdout = org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.conversionPattern = %d [%t] %-5p %c - %m%n
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/TestTransactions.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/TestTransactions.java 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/TestTransactions.java 2009-03-04 03:07:50 UTC (rev 1785)
@@ -71,12 +71,6 @@
{"tx-page-manager.xml", "transaction.xml", "interceptors.xml"};
}
- protected String[] getBootConfigurations()
- {
- return new String[]
- {"boot/datasource.xml"};
- }
-
public void testTx() throws Exception
{
if (pageManager.folderExists("/"))
Added: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/cache/DatabasePageManagerServer.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/cache/DatabasePageManagerServer.java (rev 0)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/cache/DatabasePageManagerServer.java 2009-03-04 03:07:50 UTC (rev 1785)
@@ -0,0 +1,223 @@
+/*
+ * 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.cache;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.util.Properties;
+
+import org.apache.commons.jexl.JexlContext;
+import org.apache.commons.jexl.JexlHelper;
+import org.apache.commons.jexl.Script;
+import org.apache.commons.jexl.ScriptFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.components.jndi.JetspeedTestJNDIComponent;
+import org.apache.jetspeed.engine.JetspeedEngineConstants;
+import org.apache.jetspeed.page.PageManager;
+import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * DatabasePageManagerServer
+ *
+ * @author Randy Watler
+ * @version $Id: $
+ */
+public class DatabasePageManagerServer
+{
+
+ protected static Log log = LogFactory
+ .getLog(DatabasePageManagerServer.class);
+
+ // Constants
+
+ public static final String SCRIPT_RESULT_LINE_PREFIX = "> ";
+
+ // Members
+
+ private JetspeedTestJNDIComponent jndiDS;
+
+ protected ClassPathXmlApplicationContext ctx;
+
+ private String baseDir;
+
+ private PageManager pageManager;
+
+ private JexlContext jexlContext;
+
+ private boolean exit;
+
+ // Life cycle
+
+ /**
+ * Initialize page manager server instance and script context.
+ *
+ * @throws Exception
+ */
+ public void initialize() throws Exception
+ {
+ // setup jetspeed test datasource and component manager
+ jndiDS = new JetspeedTestJNDIComponent();
+ jndiDS.setup();
+ final String[] bootConfigurations = new String[]
+ {"boot/datasource.xml"};
+ final String[] configurations = new String[]
+ {"database-page-manager.xml", "transaction.xml"};
+ baseDir = System.getProperty("basedir");
+ if ((baseDir == null) || (baseDir.length() == 0))
+ {
+ baseDir = System.getProperty("user.dir");
+ }
+ final String appRoot = baseDir + "/target/test-classes/webapp";
+ final ApplicationContext bootContext = new ClassPathXmlApplicationContext(
+ bootConfigurations, true);
+ ctx = new ClassPathXmlApplicationContext(configurations, false,
+ bootContext);
+ PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
+ Properties p = new Properties();
+ p.setProperty(JetspeedEngineConstants.APPLICATION_ROOT_KEY, appRoot);
+ ppc.setProperties(p);
+ ctx.addBeanFactoryPostProcessor(ppc);
+ ctx.refresh();
+
+ // access page manager
+ pageManager = (PageManager) ctx.getBean("pageManager");
+
+ // craete jexl context
+ jexlContext = JexlHelper.createContext();
+ jexlContext.getVars().put("pageManager", pageManager);
+ jexlContext.getVars().put("pageManagerServer", this);
+
+ log.info("DatabasePageManager server initialized");
+ }
+
+ /**
+ * Terminate page manager server instance.
+ *
+ * @throws Exception
+ */
+ public void terminate() throws Exception
+ {
+ // tear down jetspeed component manager and test datasource
+ ctx.close();
+ jndiDS.tearDown();
+
+ log.info("DatabasePageManager server terminated");
+ }
+
+ // Implementation
+
+ /**
+ * Execute a single line script against page manager server context.
+ *
+ * @param scriptLine jexl script
+ * @return script result line
+ */
+ public String execute(final String scriptLine)
+ {
+ // execute script line and return result line
+ String resultLine = scriptLine;
+ try
+ {
+ final Script jexlScript = ScriptFactory.createScript(scriptLine);
+ final Object result = jexlScript.execute(jexlContext);
+ if (result != null)
+ {
+ resultLine += " -> " + result;
+ }
+ }
+ catch (final Exception e)
+ {
+ resultLine += " -> " + e;
+ }
+ return resultLine;
+ }
+
+ /**
+ * Sets server exit flag.
+ */
+ public void exit()
+ {
+ exit = true;
+ }
+
+ // Data access
+
+ /**
+ * @return server exit flag
+ */
+ public boolean isExit()
+ {
+ return exit;
+ }
+
+ // Application entry point
+
+ /**
+ * Server main entry point.
+ *
+ * @param args not used
+ */
+ public static void main(final String[] args)
+ {
+ try
+ {
+ // create and initialize server
+ final DatabasePageManagerServer server = new DatabasePageManagerServer();
+ server.initialize();
+
+ // simple server reads script lines from standard
+ // input and writes results on standard output
+ final BufferedReader in = new BufferedReader(new InputStreamReader(
+ System.in));
+ final PrintWriter out = new PrintWriter(System.out, true);
+ do
+ {
+ // read single line scripts to execute
+ String scriptLine = in.readLine();
+ if (scriptLine != null)
+ {
+ scriptLine = scriptLine.trim();
+ String resultLine = "";
+ if (scriptLine.length() > 0)
+ {
+ // execute script
+ resultLine = server.execute(scriptLine);
+ }
+
+ // write prefixed single line results
+ out.println(SCRIPT_RESULT_LINE_PREFIX + resultLine);
+ }
+ else
+ {
+ // exit server on input EOF
+ server.exit();
+ }
+ } while (!server.isExit());
+
+ // terminate server
+ server.terminate();
+ }
+ catch (final Throwable t)
+ {
+ log.error("Unexpected exception: " + t, t);
+ }
+ }
+}
Added: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/cache/TestDatabasePageManagerCache.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/cache/TestDatabasePageManagerCache.java (rev 0)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/org/apache/jetspeed/page/cache/TestDatabasePageManagerCache.java 2009-03-04 03:07:50 UTC (rev 1785)
@@ -0,0 +1,692 @@
+/*
+ * 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.cache;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.cache.impl.EhCacheConfigResource;
+
+/**
+ * TestDatabasePageManagerCache
+ *
+ * @author Randy Watler
+ * @version $Id: $
+ */
+public class TestDatabasePageManagerCache extends TestCase
+{
+
+ protected static Log log = LogFactory
+ .getLog(TestDatabasePageManagerCache.class);
+
+ // Members
+
+ private String osExecutableExtension;
+
+ private String fileSeparator;
+
+ private File javaExecutablePath;
+
+ private String classPathSeparator;
+
+ private File projectDirectoryPath;
+
+ private Map systemProperties;
+
+ private String classPath;
+
+ // Test methods
+
+ /**
+ * Tests distributed cache operation for DatabasePageManager
+ */
+ public void testDatabasePageManagerCache()
+ {
+ String result;
+
+ // create and start servers
+ final TestProgram server0 = new TestProgram("server-0",
+ DatabasePageManagerServer.class, 0);
+ final TestProgram server1 = new TestProgram("server-1",
+ DatabasePageManagerServer.class, 1);
+ try
+ {
+ // start servers
+ server0.start();
+ server1.start();
+
+ // wait until servers have started
+ server0.execute("");
+ server1.execute("");
+
+ // check to ensure servers have distributed page manager caches
+ boolean server0Distributed = false;
+ boolean server1Distributed = false;
+ final long distributedCheckStarted = System.currentTimeMillis();
+ do
+ {
+ // check servers
+ if (!server0Distributed)
+ {
+ result = server0.execute("pageManager.isDistributed();");
+ assertTrue(result.indexOf("Exception") == -1);
+ server0Distributed = result.endsWith("true");
+ }
+ if (!server1Distributed)
+ {
+ result = server1.execute("pageManager.isDistributed();");
+ assertTrue(result.indexOf("Exception") == -1);
+ server1Distributed = result.endsWith("true");
+ }
+
+ // wait if servers not distributed
+ if (!server0Distributed || !server1Distributed)
+ {
+ Thread.sleep(250);
+ }
+ } while ((!server0Distributed || !server1Distributed)
+ && (System.currentTimeMillis() - distributedCheckStarted < 5000));
+ if (!server0Distributed && !server1Distributed)
+ {
+ System.out
+ .println("Server page managers not distributed: possible system limitation... test skipped");
+ log
+ .warn("Server page managers not distributed: possible system limitation... test skipped");
+ return;
+ }
+ assertTrue(server0Distributed);
+ assertTrue(server1Distributed);
+
+ // clean and setup database page managers
+ result = server0
+ .execute("removeRootFolder = pageManager.getFolder(\"/\");");
+ if (result.indexOf("FolderNotFoundException") == -1)
+ {
+ result = server0
+ .execute("pageManager.removeFolder(removeRootFolder);");
+ assertTrue(result.indexOf("Exception") == -1);
+ }
+ result = server0.execute("pageManager.reset();");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server1.execute("pageManager.reset();");
+ assertTrue(result.indexOf("Exception") == -1);
+
+ // create folder and documents in first page manager
+ result = server0.execute("folder = pageManager.newFolder(\"/\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("folder.setTitle(\"Root Folder\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("pageManager.updateFolder(folder);");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0
+ .execute("page = pageManager.newPage(\"/default-page.psml\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("page.setTitle(\"Default Page\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("pageManager.updatePage(page);");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0
+ .execute("page = pageManager.newPage(\"/another-page.psml\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("page.setTitle(\"Another Page\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("pageManager.updatePage(page);");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0
+ .execute("page = pageManager.newPage(\"/some-other-page.psml\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("page.setTitle(\"Some Other Page\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("pageManager.updatePage(page);");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0
+ .execute("link = pageManager.newLink(\"/default.link\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("link.setTitle(\"Default Link\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0
+ .execute("link.setUrl(\"http://www.default.org/\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("pageManager.updateLink(link);");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0
+ .execute("folder = pageManager.newFolder(\"/deep-0\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("folder.setTitle(\"Deep 0 Folder\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("pageManager.updateFolder(folder);");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0
+ .execute("page = pageManager.newPage(\"/deep-0/deep-page-0.psml\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("page.setTitle(\"Deep Page 0\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("pageManager.updatePage(page);");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0
+ .execute("folder = pageManager.newFolder(\"/deep-1\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("folder.setTitle(\"Deep 1 Folder\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("pageManager.updateFolder(folder);");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0
+ .execute("page = pageManager.newPage(\"/deep-1/deep-page-1.psml\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("page.setTitle(\"Deep Page 1\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0.execute("pageManager.updatePage(page);");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0
+ .execute("pageSecurity = pageManager.newPageSecurity();");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server0
+ .execute("pageManager.updatePageSecurity(pageSecurity);");
+ assertTrue(result.indexOf("Exception") == -1);
+
+ // populate folders and documents in second page manager
+ result = server1
+ .execute("pageManager.getFolder(\"/\").getTitle();");
+ assertTrue(result.endsWith("Root Folder"));
+ result = server1
+ .execute("pageManager.getPage(\"/default-page.psml\").getTitle();");
+ assertTrue(result.endsWith("Default Page"));
+ result = server1
+ .execute("pageManager.getPage(\"/another-page.psml\").getTitle();");
+ assertTrue(result.endsWith("Another Page"));
+ result = server1
+ .execute("pageManager.getPage(\"/some-other-page.psml\").getTitle();");
+ assertTrue(result.endsWith("Some Other Page"));
+ result = server1
+ .execute("pageManager.getLink(\"/default.link\").getTitle();");
+ assertTrue(result.endsWith("Default Link"));
+ result = server1
+ .execute("pageManager.getFolder(\"/deep-0\").getTitle();");
+ assertTrue(result.endsWith("Deep 0 Folder"));
+ result = server1
+ .execute("pageManager.getPage(\"/deep-0/deep-page-0.psml\").getTitle();");
+ assertTrue(result.endsWith("Deep Page 0"));
+ result = server1
+ .execute("pageManager.getFolder(\"/deep-1\").getTitle();");
+ assertTrue(result.endsWith("Deep 1 Folder"));
+ result = server1
+ .execute("pageManager.getPage(\"/deep-1/deep-page-1.psml\").getTitle();");
+ assertTrue(result.endsWith("Deep Page 1"));
+ result = server1
+ .execute("pageManager.getPageSecurity().getPath();");
+ assertTrue(result.endsWith("/page.security"));
+
+ // update/remove objects in second page manager
+ result = server1
+ .execute("page = pageManager.getPage(\"/default-page.psml\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server1.execute("page.setTitle(\"Edited Default Page\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server1.execute("pageManager.updatePage(page);");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server1
+ .execute("page = pageManager.getPage(\"/some-other-page.psml\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server1.execute("pageManager.removePage(page);");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server1
+ .execute("link = pageManager.getLink(\"/default.link\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server1.execute("link.setTitle(\"Edited Default Link\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server1.execute("pageManager.updateLink(link);");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server1
+ .execute("folder = pageManager.getFolder(\"/deep-0\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server1
+ .execute("folder.setTitle(\"Edited Deep 0 Folder\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server1.execute("pageManager.updateFolder(folder);");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server1
+ .execute("folder = pageManager.getFolder(\"/deep-1\");");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server1.execute("pageManager.removeFolder(folder);");
+ assertTrue(result.indexOf("Exception") == -1);
+
+ // test objects in both page managers for cache coherency
+ result = server1
+ .execute("pageManager.getPage(\"/default-page.psml\").getTitle();");
+ assertTrue(result.endsWith("Edited Default Page"));
+ result = server1
+ .execute("pageManager.getPage(\"/some-other-page.psml\");");
+ assertTrue(result.indexOf("PageNotFoundException") != -1);
+ result = server1
+ .execute("pageManager.getFolder(\"/\").getPages().size();");
+ assertTrue(result.endsWith("2"));
+ result = server1
+ .execute("pageManager.getLink(\"/default.link\").getTitle();");
+ assertTrue(result.endsWith("Edited Default Link"));
+ result = server1
+ .execute("pageManager.getFolder(\"/deep-0\").getTitle();");
+ assertTrue(result.endsWith("Edited Deep 0 Folder"));
+ result = server1
+ .execute("pageManager.getPage(\"/deep-1/deep-page-1.psml\");");
+ assertTrue(result.indexOf("PageNotFoundException") != -1);
+ result = server1.execute("pageManager.getFolder(\"/deep-1\");");
+ assertTrue(result.indexOf("FolderNotFoundException") != -1);
+ result = server1
+ .execute("pageManager.getFolder(\"/\").getFolders().size();");
+ assertTrue(result.endsWith("1"));
+ boolean defaultPageUpdated = false;
+ boolean someOtherPageRemoved = false;
+ boolean rootFolderPagesCountTwo = false;
+ boolean defaultLinkUpdated = false;
+ boolean deep0FolderUpdated = false;
+ boolean deepPage1Removed = false;
+ boolean deep1FolderRemoved = false;
+ boolean rootFolderFoldersCountOne = false;
+ final long coherencyCheckStarted = System.currentTimeMillis();
+ do
+ {
+ // check cache coherency
+ if (!defaultPageUpdated)
+ {
+ result = server0
+ .execute("pageManager.getPage(\"/default-page.psml\").getTitle();");
+ defaultPageUpdated = result.endsWith("Edited Default Page");
+ }
+ if (!someOtherPageRemoved)
+ {
+ result = server0
+ .execute("pageManager.getPage(\"/some-other-page.psml\");");
+ someOtherPageRemoved = (result
+ .indexOf("PageNotFoundException") != -1);
+ }
+ if (!rootFolderPagesCountTwo)
+ {
+ result = server0
+ .execute("pageManager.getFolder(\"/\").getPages().size();");
+ rootFolderPagesCountTwo = result.endsWith("2");
+ }
+ if (!defaultLinkUpdated)
+ {
+ result = server0
+ .execute("pageManager.getLink(\"/default.link\").getTitle();");
+ defaultLinkUpdated = result.endsWith("Edited Default Link");
+ }
+ if (!deep0FolderUpdated)
+ {
+ result = server0
+ .execute("pageManager.getFolder(\"/deep-0\").getTitle();");
+ deep0FolderUpdated = result
+ .endsWith("Edited Deep 0 Folder");
+ }
+ if (!deepPage1Removed)
+ {
+ result = server0
+ .execute("pageManager.getPage(\"/deep-1/deep-page-1.psml\");");
+ deepPage1Removed = (result.indexOf("PageNotFoundException") != -1);
+ }
+ if (!deep1FolderRemoved)
+ {
+ result = server0
+ .execute("pageManager.getFolder(\"/deep-1\");");
+ deep1FolderRemoved = (result
+ .indexOf("FolderNotFoundException") != -1);
+ }
+ if (!rootFolderFoldersCountOne)
+ {
+ result = server0
+ .execute("pageManager.getFolder(\"/\").getFolders().size();");
+ rootFolderFoldersCountOne = result.endsWith("1");
+ }
+
+ // wait for cache coherency
+ if (!defaultPageUpdated || !someOtherPageRemoved
+ || !rootFolderPagesCountTwo || !defaultLinkUpdated
+ || !deep0FolderUpdated || !deepPage1Removed
+ || !deep1FolderRemoved || !rootFolderFoldersCountOne)
+ {
+ Thread.sleep(250);
+ }
+ } while ((!defaultPageUpdated || !someOtherPageRemoved
+ || !rootFolderPagesCountTwo || !defaultLinkUpdated
+ || !deep0FolderUpdated || !deepPage1Removed
+ || !deep1FolderRemoved || !rootFolderFoldersCountOne)
+ && (System.currentTimeMillis() - coherencyCheckStarted < 5000));
+ assertTrue(defaultPageUpdated);
+ assertTrue(someOtherPageRemoved);
+ assertTrue(rootFolderPagesCountTwo);
+ assertTrue(defaultLinkUpdated);
+ assertTrue(deep0FolderUpdated);
+ assertTrue(deepPage1Removed);
+ assertTrue(deep1FolderRemoved);
+ assertTrue(rootFolderFoldersCountOne);
+
+ // reset database page managers
+ result = server0.execute("pageManager.reset();");
+ assertTrue(result.indexOf("Exception") == -1);
+ result = server1.execute("pageManager.reset();");
+ assertTrue(result.indexOf("Exception") == -1);
+ }
+ catch (final Exception e)
+ {
+ log.error("Server test exception: " + e, e);
+ fail("Server test exception: " + e);
+ }
+ finally
+ {
+ // silently shutdown servers
+ try
+ {
+ server0.shutdown();
+ }
+ catch (final Exception e)
+ {
+ log.error("Server shutdown exception: " + e, e);
+ }
+ try
+ {
+ server1.shutdown();
+ }
+ catch (final Exception e)
+ {
+ log.error("Server shutdown exception: " + e, e);
+ }
+ }
+ }
+
+ // Implementation classes
+
+ protected class TestProgram
+ {
+
+ private String name;
+
+ private Class mainClass;
+
+ private int index;
+
+ private Process process;
+
+ private BufferedWriter processInput;
+
+ private BufferedReader processOutput;
+
+ public TestProgram(final String name, final Class mainClass,
+ final int index)
+ {
+ this.name = name;
+ this.mainClass = mainClass;
+ this.index = index;
+ }
+
+ public synchronized void start() throws IOException
+ {
+ assertNull(process);
+
+ // configure launcher with paths, properties, and indexed properties
+ final List commandAndArgs = new ArrayList();
+ commandAndArgs.add(javaExecutablePath.getCanonicalPath());
+ for (Iterator iter = systemProperties.entrySet().iterator(); iter
+ .hasNext();)
+ {
+ final Map.Entry systemProperty = (Map.Entry) iter.next();
+ final String propertyName = (String) systemProperty.getKey();
+ String propertyValue = (String) systemProperty.getValue();
+ if (propertyName
+ .equals(EhCacheConfigResource.EHCACHE_PORT_PROP_NAME))
+ {
+ propertyValue = Integer.toString(Integer
+ .parseInt(propertyValue)
+ + index);
+ }
+ commandAndArgs.add("-D" + propertyName + "=" + propertyValue);
+ }
+ commandAndArgs.add("-Dlog4j.configuration=log4j-stdout.properties");
+ commandAndArgs.add("-classpath");
+ commandAndArgs.add(classPath);
+ commandAndArgs.add(mainClass.getName());
+
+ // launch test programs
+ process = Runtime.getRuntime().exec(
+ (String[]) commandAndArgs.toArray(new String[commandAndArgs
+ .size()]), null, projectDirectoryPath);
+
+ // setup I/O for process
+ processInput = new BufferedWriter(new OutputStreamWriter(process
+ .getOutputStream()));
+ processOutput = new BufferedReader(new InputStreamReader(process
+ .getInputStream()));
+
+ // read messages from process
+ for (String line; (processOutput.ready() && ((line = processOutput
+ .readLine()) != null));)
+ {
+ logProcessLine(line);
+ }
+ }
+
+ public synchronized String execute(final String scriptLine)
+ throws IOException
+ {
+ assertNotNull(process);
+
+ // read messages from process
+ for (String line; (processOutput.ready() && ((line = processOutput
+ .readLine()) != null));)
+ {
+ logProcessLine(line);
+ }
+
+ // write script line to process
+ processInput.write(scriptLine);
+ processInput.newLine();
+ processInput.flush();
+
+ // read result or messages from process
+ String resultLine = null;
+ for (String line; ((line = processOutput.readLine()) != null);)
+ {
+ if (!line
+ .startsWith(DatabasePageManagerServer.SCRIPT_RESULT_LINE_PREFIX))
+ {
+ logProcessLine(line);
+ }
+ else
+ {
+ resultLine = line;
+ break;
+ }
+ }
+ if (resultLine == null) { throw new IOException(
+ "Unexpected EOF from process output"); }
+ return resultLine;
+ }
+
+ public synchronized void shutdown() throws IOException,
+ InterruptedException
+ {
+ assertNotNull(process);
+
+ // start thread to destroy process on timeout
+ final Thread destroyThread = new Thread(new Runnable()
+ {
+
+ public void run()
+ {
+ try
+ {
+ Thread.sleep(10000);
+ if (process != null)
+ {
+ log.warn("Forcibly stopping " + name);
+ process.destroy();
+ }
+ }
+ catch (final Exception e)
+ {
+ }
+ }
+ }, "DestroyThread");
+ destroyThread.setDaemon(true);
+ destroyThread.start();
+
+ // close process input to shutdown server and read messages
+ processInput.close();
+ for (String line; ((line = processOutput.readLine()) != null);)
+ {
+ logProcessLine(line);
+ }
+
+ // join on process completion
+ process.waitFor();
+ processOutput.close();
+ process = null;
+
+ // join on destroy thread
+ destroyThread.interrupt();
+ destroyThread.join();
+ }
+
+ private void logProcessLine(final String line)
+ {
+ if ((line.indexOf("ERROR") == -1)
+ && ((line.indexOf("ERROR") != -1)
+ || (line.indexOf("Exception") != -1) || line
+ .startsWith(" at ")))
+ {
+ log.error("{" + name + "} " + line);
+ }
+ else
+ {
+ log.info("{" + name + "} " + line);
+ }
+ }
+ }
+
+ // TestCase implementation
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ // setup cache properties
+ EhCacheConfigResource
+ .getInstance(
+ EhCacheConfigResource.EHCACHE_CONFIG_RESOURCE_DISTRIBUTED_CACHE,
+ true);
+
+ // environment setup
+ osExecutableExtension = (System.getProperty("os.name").startsWith(
+ "Windows") ? ".exe" : "");
+ fileSeparator = System.getProperty("file.separator");
+ javaExecutablePath = new File(System.getProperty("java.home")
+ + fileSeparator + "bin" + fileSeparator + "java"
+ + osExecutableExtension);
+ classPathSeparator = System.getProperty("path.separator");
+ projectDirectoryPath = new File(System.getProperty("basedir"));
+ systemProperties = new HashMap();
+ for (Iterator iter = System.getProperties().entrySet().iterator(); iter
+ .hasNext();)
+ {
+ final Map.Entry systemProperty = (Map.Entry) iter.next();
+ final String propertyName = systemProperty.getKey().toString();
+ final String propertyValue = systemProperty.getValue().toString();
+ if (propertyName.startsWith("org.apache.jetspeed.")
+ || propertyName.startsWith("java.net.")
+ || propertyName.equals("basedir"))
+ {
+ systemProperties.put(propertyName, propertyValue);
+ }
+ }
+
+ // construct launcher classpath from current class loader
+ final StringBuffer classPathBuilder = new StringBuffer();
+ final ClassLoader loader = this.getClass().getClassLoader();
+ assertTrue(loader instanceof URLClassLoader);
+ final URLClassLoader urlLoader = (URLClassLoader) loader;
+ assertNotNull(urlLoader.getURLs());
+ for (int i = 0; (i < urlLoader.getURLs().length); i++)
+ {
+ final URL pathURL = urlLoader.getURLs()[i];
+
+ // convert path URL to file path
+ final String path = new File(new URI(pathURL.toString()))
+ .getCanonicalPath();
+
+ // build class path
+ if (classPathBuilder.length() > 0)
+ {
+ classPathBuilder.append(classPathSeparator);
+ }
+ classPathBuilder.append(path);
+ }
+ classPath = classPathBuilder.toString();
+ assertTrue(classPath.length() > 0);
+
+ // continue setup
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ // Application entry point
+
+ /**
+ * Start the tests.
+ *
+ * @param args not used
+ */
+ public static void main(final String[] args)
+ {
+ junit.awtui.TestRunner.main(new String[]
+ {TestDatabasePageManagerCache.class.getName()});
+ }
+
+ /**
+ * Creates the test suite.
+ *
+ * @return a test suite that includes all methods starting with "test"
+ */
+ public static Test suite()
+ {
+ return new TestSuite(TestDatabasePageManagerCache.class);
+ }
+}
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/secure-database-page-manager.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/secure-database-page-manager.xml 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/secure-database-page-manager.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -18,65 +18,20 @@
-->
+
+
-
+ JETSPEED-INF/ojb/page-manager-repository.xml
-
- 128
-
- 0
- false
+ false
- true
+ true
+
+
+
+
-
-
-
- org.apache.jetspeed.page.PageManager
-
-
-
-
-
-
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
-
-
-
-
-
-
-
- setPageManagerProxy
-
-
-
-
-
-
-
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/secure-permissions-database-page-manager.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/secure-permissions-database-page-manager.xml 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/secure-permissions-database-page-manager.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -18,65 +18,20 @@
-->
+
+
-
+ JETSPEED-INF/ojb/page-manager-repository.xml
-
- 128
-
- 0
- true
+ true
- false
+ false
+
+
+
+
-
-
-
- org.apache.jetspeed.page.PageManager
-
-
-
-
-
-
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
-
-
-
-
-
-
-
- setPageManagerProxy
-
-
-
-
-
-
-
Deleted: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/tx-page-manager.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/tx-page-manager.xml 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/src/test/tx-page-manager.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -1,82 +0,0 @@
-
-
-
-
-
-
-
-
- JETSPEED-INF/ojb/page-manager-repository.xml
-
- 128
-
- 0
-
- false
-
- false
-
-
-
-
-
- org.apache.jetspeed.page.PageManager
-
-
-
-
-
-
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_REQUIRED,-org.apache.jetspeed.page.document.NodeException
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
- PROPAGATION_SUPPORTS
-
-
-
-
-
-
-
- setPageManagerProxy
-
-
-
-
-
-
-
-
Added: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/db-ojb/distributed-ehcache.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/db-ojb/distributed-ehcache.xml (rev 0)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/db-ojb/distributed-ehcache.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -0,0 +1,543 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/db-ojb/ehcache.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/db-ojb/ehcache.xml 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/db-ojb/ehcache.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -135,13 +135,7 @@
* stashRemoteCachePeers (optional) - specify "true" or "false". Defaults to true.
CachePeer objects are stashed for performance.
* jndiUrls (mandatory) - specify a pipe separated list of jndiUrls,
- in the form protocol//hostname:port
-
-
+ in the form protocol//hostname:port
-->
@@ -185,9 +179,6 @@
net.sf.ehcache.distribution.JNDIManualRMICacheManagerPeerProviderFactoryerFactory.
Properties for JNDIRMICacheManagerPeerListenerFactory are the same as
RMICacheManagerPeerListenerFactory.
-
-
-->
@@ -332,8 +323,7 @@
If there are more than 10000 elements it will overflow to the
disk cache, which in this configuration will go to wherever java.io.tmp is
- defined on your system. On a standard Linux system this will be /tmp"
-
+ defined on your system. On a standard Linux system this will be /tmp
timeToIdleSeconds and timeToLiveSeconds to live are both set at 8 hours (28800)
this is the default setting for portlets who set their expiration cache as -1
-->
@@ -355,13 +345,6 @@
timeToIdleSeconds="28800"
timeToLiveSeconds="28800"
memoryStoreEvictionPolicy="LFU">
-
@@ -383,13 +366,6 @@
timeToIdleSeconds="28800"
timeToLiveSeconds="28800"
memoryStoreEvictionPolicy="LFU">
-
-
@@ -541,4 +510,24 @@
memoryStoreEvictionPolicy="LFU"
/>
+
+
+
+
+
+
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/import/assembly/import-page-manager.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/import/assembly/import-page-manager.xml 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/import/assembly/import-page-manager.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -24,14 +24,14 @@
class="org.apache.jetspeed.page.impl.DatabasePageManager">
JETSPEED-INF/ojb/page-manager-repository.xml
-
- 128
-
- 0
- false
+ false
- false
+ false
+
+
+
+
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/import/build.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/import/build.xml 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/import/build.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -89,6 +89,7 @@
+
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/import/export.properties
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/import/export.properties 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/import/export.properties 2009-03-04 03:07:50 UTC (rev 1785)
@@ -16,7 +16,7 @@
# comma-separated list of boot assemblies for Spring
boot.assemblies = repository-datasource-spring.xml
# comma-separated list of assemblies for Spring
-assemblies = import-page-manager.xml, transaction.xml, interceptors.xml
+assemblies = import-page-manager.xml, transaction.xml, interceptors.xml, cache.xml
# root folder to start importing from
root.folder = /
# overwrite folders flag, set to true to replace existing folders
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/import/import.properties
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/import/import.properties 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/etc/import/import.properties 2009-03-04 03:07:50 UTC (rev 1785)
@@ -16,7 +16,7 @@
# comma-separated list of boot assemblies for Spring
boot.assemblies = repository-datasource-spring.xml
# comma-separated list of assemblies for Spring
-assemblies = import-page-manager.xml, transaction.xml, interceptors.xml
+assemblies = import-page-manager.xml, transaction.xml, interceptors.xml, cache.xml
# root folder to start exporting from
root.folder = /
# overwrite folders flag, set to true to replace existing folders
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/cache/JetspeedCache.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/cache/JetspeedCache.java 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/cache/JetspeedCache.java 2009-03-04 03:07:50 UTC (rev 1785)
@@ -145,4 +145,11 @@
* @return the size of the cache
*/
int getSize();
+
+ /**
+ * Returns whether this cache is currently part of a distributed cache cluster.
+ *
+ * @return distributed flag
+ */
+ boolean isDistributed();
}
\ No newline at end of file
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/page/PageManager.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/page/PageManager.java 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/page/PageManager.java 2009-03-04 03:07:50 UTC (rev 1785)
@@ -781,4 +781,13 @@
* @return
*/
public boolean checkConstraint(String securityConstraintName, String actions);
+
+ /**
+ * Returns whether the page manager cache is currently part of a distributed
+ * cache cluster.
+ *
+ * @return distributed flag
+ */
+ public boolean isDistributed();
+
}
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/maven.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/maven.xml 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/maven.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -348,6 +348,8 @@
file="./src/webapp/WEB-INF/assembly/transaction.xml"/>
+
@@ -385,6 +387,8 @@
file="./src/webapp/WEB-INF/assembly/transaction.xml"/>
+
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/alternate/db-page-manager.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/alternate/db-page-manager.xml 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/alternate/db-page-manager.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -25,15 +25,14 @@
class="org.apache.jetspeed.page.impl.DatabasePageManager">
JETSPEED-INF/ojb/page-manager-repository.xml
-
- 128
-
-
- -1
- false
+ false
- true
+ true
+
+
+
+
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/cache.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/cache.xml 2009-02-25 13:40:55 UTC (rev 1784)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/cache.xml 2009-03-04 03:07:50 UTC (rev 1785)
@@ -18,11 +18,14 @@
-->
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From svnnotify @ sourceforge.jp Wed Mar 4 13:23:20 2009
From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp)
Date: Wed, 04 Mar 2009 13:23:20 +0900
Subject: [pal-cvs 4051] [1786] applied patch 'r725897: M1 Build Fixes For
Distributed Cache Backport'
Message-ID: <1236140600.803605.24237.nullmailer@users.sourceforge.jp>
Revision: 1786
http://svn.sourceforge.jp/view?root=pal&view=rev&rev=1786
Author: sone
Date: 2009-03-04 13:23:20 +0900 (Wed, 04 Mar 2009)
Log Message:
-----------
applied patch 'r725897: M1 Build Fixes For Distributed Cache Backport'
Modified Paths:
--------------
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/project.xml
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/core-build.xml
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/cache.xml
-------------- next part --------------
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/project.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/project.xml 2009-03-04 03:07:50 UTC (rev 1785)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/project.xml 2009-03-04 04:23:20 UTC (rev 1786)
@@ -95,6 +95,7 @@
**/PageManagerTestShared.java**/DirectoryXMLTransform.java
+ **/DatabasePageManagerServer.java
@@ -115,6 +116,10 @@
${basedir}/../../etc/db-ojb
+
+ **/ehcache.xml
+ **/distributed-ehcache.xml
+ ${basedir}/../../src/webapp/WEB-INF/assembly
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/core-build.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/core-build.xml 2009-03-04 03:07:50 UTC (rev 1785)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/core-build.xml 2009-03-04 04:23:20 UTC (rev 1786)
@@ -106,11 +106,25 @@
ehcache
- 1.2.4
+ 1.5.0true
+
+ backport-util-concurrent
+ 3.1
+
+ true
+
+
+
+ jsr107cache
+ 1.0
+
+ true
+
+
@@ -251,6 +265,13 @@
false
+
+ commons-jexl
+ 1.1
+
+ false
+
+
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/cache.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/cache.xml 2009-03-04 03:07:50 UTC (rev 1785)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/cache.xml 2009-03-04 04:23:20 UTC (rev 1786)
@@ -20,6 +20,7 @@
+
From svnnotify @ sourceforge.jp Wed Mar 4 13:36:19 2009
From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp)
Date: Wed, 04 Mar 2009 13:36:19 +0900
Subject: [pal-cvs 4052] [1787] applied patch r725921: patched failing test
case under M1
Message-ID: <1236141379.965631.12661.nullmailer@users.sourceforge.jp>
Revision: 1787
http://svn.sourceforge.jp/view?root=pal&view=rev&rev=1787
Author: sone
Date: 2009-03-04 13:36:19 +0900 (Wed, 04 Mar 2009)
Log Message:
-----------
applied patch r725921: patched failing test case under M1
Modified Paths:
--------------
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal/src/test/org/apache/jetspeed/container/state/TestNavigationalState.java
-------------- next part --------------
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal/src/test/org/apache/jetspeed/container/state/TestNavigationalState.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal/src/test/org/apache/jetspeed/container/state/TestNavigationalState.java 2009-03-04 04:23:20 UTC (rev 1786)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/portal/src/test/org/apache/jetspeed/container/state/TestNavigationalState.java 2009-03-04 04:36:19 UTC (rev 1787)
@@ -131,6 +131,9 @@
portletApplicationMock.expects(new AnyArgumentsMatcher()).method(
"getId").withNoArguments().will(
new ReturnStub(new JetspeedLongObjectID(1)));
+ portletApplicationMock.expects(new AnyArgumentsMatcher()).method(
+ "getName").withNoArguments().will(new ReturnStub("app1"));
+
portletDefinitionMock.expects(new AnyArgumentsMatcher()).method(
"getPortletApplicationDefinition").withNoArguments().will(
new ReturnStub(portletApplicationMock.proxy()));
From svnnotify @ sourceforge.jp Wed Mar 4 14:38:03 2009
From: svnnotify @ sourceforge.jp (svnnotify @ sourceforge.jp)
Date: Wed, 04 Mar 2009 14:38:03 +0900
Subject: [pal-cvs 4053] [1788] applied patch 'r740489: Backport of
preferences fix'
Message-ID: <1236145083.709429.15057.nullmailer@users.sourceforge.jp>
Revision: 1788
http://svn.sourceforge.jp/view?root=pal&view=rev&rev=1788
Author: sone
Date: 2009-03-04 14:38:03 +0900 (Wed, 04 Mar 2009)
Log Message:
-----------
applied patch 'r740489: Backport of preferences fix'
Modified Paths:
--------------
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/page-manager/project.xml
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesFactoryImpl.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesImpl.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/prefs.xml
Added Paths:
-----------
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/org/apache/jetspeed/util/PreferencesRootWrapper.java
pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PreferencesProviderWrapper.java
-------------- next part --------------
Added: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/org/apache/jetspeed/util/PreferencesRootWrapper.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/org/apache/jetspeed/util/PreferencesRootWrapper.java (rev 0)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/commons/src/java/org/apache/jetspeed/util/PreferencesRootWrapper.java 2009-03-04 05:38:03 UTC (rev 1788)
@@ -0,0 +1,237 @@
+/*
+ * 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.util;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Observable;
+import java.util.Observer;
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.NodeChangeListener;
+import java.util.prefs.PreferenceChangeListener;
+import java.util.prefs.Preferences;
+
+/**
+ * PreferencesRootWrapper is a lightweight wrapper around the Jetspeed persistent PreferencesImpl to allow
+ * restarting the Jetspeed Portal.
+ *
+ * As the (Sun) Java Preferences implementation only creates a PreferencesFactory instance *once* per JVM
+ * (as static final), reloading the Jetspeed Portal (using a new classloader) requires a wrapper solution
+ * to prevent ClassCastExceptions and/or out-of-sync kept proxies and caches.
+ *
+ *
+ * As a newly created Jetspeed Portal classloader can no longer cast a previous Preferences root to its
+ * own PreferencesImpl, a "trick" is used by also implementing the Observer interface (which is provided by
+ * the Java system classloader). The Observer interface is used because it is very lightweight and allows
+ * passing an Object instance through its update method. That update method is used to "inject" the newly
+ * created Preferences root instance.
+ *