Author: taylor
Date: Mon Feb 12 18:47:07 2007
New Revision: 506825
URL: http://svn.apache.org/viewvc?view=rev&rev=506825
Log:
https://issues.apache.org/jira/browse/JS2-654
got myself into a cyclical build error
had to do some refactoring of the cache impl, and move the cache configuration
into the classpath
build is passing allTest now
Added:
portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/
portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheElementImpl.java
portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java
portals/jetspeed-2/trunk/etc/db-ojb/ehcache.xml
- copied unchanged from r506764,
portals/jetspeed-2/trunk/src/webapp/WEB-INF/conf/ehcache.xml
Removed:
portals/jetspeed-2/trunk/src/webapp/WEB-INF/conf/ehcache.xml
Modified:
portals/jetspeed-2/trunk/components/portal/maven.xml
portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java
portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/util/test/AbstractPrefsSupportedTestCase.java
portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferences.java
portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesNoPropManager.java
portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesProvider.java
portals/jetspeed-2/trunk/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java
portals/jetspeed-2/trunk/components/registry/src/test/org/apache/jetspeed/components/portletregistry/AbstractRegistryTest.java
portals/jetspeed-2/trunk/components/registry/src/test/org/apache/jetspeed/components/portletregistry/TestPortletRegistryDAO.java
portals/jetspeed-2/trunk/components/security/maven.xml
portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/TestUserSecurityHandler.java
portals/jetspeed-2/trunk/etc/build.xml
portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/cache.xml
Added:
portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheElementImpl.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheElementImpl.java?view=auto&rev=506825
==============================================================================
---
portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheElementImpl.java
(added)
+++
portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheElementImpl.java
Mon Feb 12 18:47:07 2007
@@ -0,0 +1,94 @@
+/* Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed 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 net.sf.ehcache.Element;
+
+import org.apache.jetspeed.cache.CacheElement;
+
+/**
+ * Wrapper around actual cache element implementation
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class EhCacheElementImpl implements CacheElement
+{
+ Element element;
+ public static final String KEY_SEPARATOR = "/";
+
+ public EhCacheElementImpl(Element element)
+ {
+ this.element = element;
+ }
+
+ public Object getKey()
+ {
+ return element.getObjectKey();
+ }
+
+ public String getUserKey()
+ {
+ String key = (String)element.getObjectKey();
+ return key.substring(0, key.indexOf(KEY_SEPARATOR));
+ }
+
+ public String getEntityKey()
+ {
+ String key = (String)element.getObjectKey();
+ return key.substring(key.indexOf(KEY_SEPARATOR) + 1);
+ }
+
+ public Object getContent()
+ {
+ return element.getObjectValue();
+ }
+
+ public int getTimeToIdleSeconds()
+ {
+ return element.getTimeToIdle();
+ }
+
+ public int getTimeToLiveSeconds()
+ {
+ return element.getTimeToLive();
+ }
+
+ public boolean isEternal()
+ {
+ return element.isEternal();
+ }
+
+ public Element getImplElement()
+ {
+ return element;
+ }
+
+ public void setEternal(boolean eternal)
+ {
+ element.setEternal(eternal);
+ }
+
+ public void setTimeToIdleSeconds(int timeToIdle)
+ {
+ element.setTimeToIdle(timeToIdle);
+ }
+
+ public void setTimeToLiveSeconds(int timeToLive)
+ {
+ element.setTimeToLive(timeToLive);
+ }
+}
\ No newline at end of file
Added:
portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java?view=auto&rev=506825
==============================================================================
---
portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java
(added)
+++
portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java
Mon Feb 12 18:47:07 2007
@@ -0,0 +1,143 @@
+/* Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import net.sf.ehcache.Cache;
+import net.sf.ehcache.Element;
+
+import org.apache.jetspeed.cache.CacheElement;
+import org.apache.jetspeed.cache.JetspeedCache;
+
+/**
+ * Wrapper around actual cache implementation
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class EhCacheImpl implements JetspeedCache
+{
+ private Cache ehcache;
+
+ public EhCacheImpl(Cache ehcache)
+ {
+ this.ehcache = ehcache;
+ }
+
+ public CacheElement get(Object key)
+ {
+ Element element = ehcache.get(key);
+ if (element == null)
+ return null;
+ return new EhCacheElementImpl(element);
+ }
+
+ public int getTimeToIdleSeconds()
+ {
+ return (int)ehcache.getTimeToIdleSeconds();
+ }
+
+ public int getTimeToLiveSeconds()
+ {
+ return (int)ehcache.getTimeToLiveSeconds();
+ }
+
+ public boolean isKeyInCache(Object key)
+ {
+ return ehcache.isKeyInCache(key);
+ }
+
+ public void put(CacheElement element)
+ {
+ EhCacheElementImpl impl = (EhCacheElementImpl)element;
+ Element ehl = impl.getImplElement();
+ String userKey = impl.getUserKey();
+ String entity = impl.getEntityKey();
+ ehcache.put(ehl);
+ Element userElement = ehcache.get(userKey);
+ if (userElement == null)
+ {
+ Map map = Collections.synchronizedMap(new HashMap());
+ map.put(entity, entity);
+ userElement = new Element(userKey, map);
+ ehcache.put(userElement);
+ }
+ else
+ {
+ Map map = (Map)userElement.getObjectValue();
+ map.put(entity, entity);
+ }
+ }
+
+ public CacheElement createElement(Object key, Object content)
+ {
+ Element cachedElement = new Element(key, content);
+ return new EhCacheElementImpl(cachedElement);
+ }
+
+ public boolean remove(Object key)
+ {
+ CacheElement element = this.get(key);
+ boolean removed = false;
+ if (element == null)
+ return false;
+ removed = ehcache.remove(key);
+ EhCacheElementImpl impl = (EhCacheElementImpl)element;
+ Element ehl = impl.getImplElement();
+ String userKey = impl.getUserKey();
+ String entity = impl.getEntityKey();
+ Element userElement = ehcache.get(userKey);
+ if (userElement != null)
+ {
+ Map map = (Map)userElement.getObjectValue();
+ if (map != null)
+ {
+ map.remove(entity);
+ }
+ }
+ return removed;
+ }
+
+ public void evictContentForUser(String user)
+ {
+ Element userElement = ehcache.get(user);
+ if (userElement != null)
+ {
+ Map map = (Map)userElement.getObjectValue();
+ if (map != null)
+ {
+ Iterator entities = map.keySet().iterator();
+ while (entities.hasNext())
+ {
+ String entity = (String)entities.next();
+ String key = createCacheKey(user, entity);
+ ehcache.remove(key);
+ }
+ }
+ ehcache.remove(user);
+ }
+ }
+
+ public String createCacheKey(String primary, String secondary)
+ {
+ return primary + EhCacheElementImpl.KEY_SEPARATOR + secondary;
+ }
+
+}
\ No newline at end of file
Modified: portals/jetspeed-2/trunk/components/portal/maven.xml
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/maven.xml?view=diff&rev=506825&r1=506824&r2=506825
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/maven.xml (original)
+++ portals/jetspeed-2/trunk/components/portal/maven.xml Mon Feb 12 18:47:07
2007
@@ -17,6 +17,6 @@
<project default="java:jar" xmlns:j="jelly:core" xmlns:define="jelly:define"
xmlns:maven="jelly:maven">
<!-- Target of maven test:single test -->
- <property name='testcase'
value='org.apache.jetspeed.tools.pamanager.TestPortletDescriptor' />
+ <property name='testcase'
value='org.apache.jetspeed.userinfo.TestUserInfoManager' />
</project>
Modified:
portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java?view=diff&rev=506825&r1=506824&r2=506825
==============================================================================
---
portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java
(original)
+++
portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java
Mon Feb 12 18:47:07 2007
@@ -79,8 +79,8 @@
*/
public void tearDown() throws Exception
{
- super.tearDown();
cleanUp();
+ super.tearDown();
}
public static Test suite()
@@ -249,6 +249,8 @@
confList.add("registry.xml");
confList.add("rc3.xml");
confList.add("JETSPEED-INF/spring/user-info.xml");
+ confList.add("prefs.xml");
+ confList.add("cache.xml");
return (String[]) confList.toArray(new String[1]);
}
}
Modified:
portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/util/test/AbstractPrefsSupportedTestCase.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/util/test/AbstractPrefsSupportedTestCase.java?view=diff&rev=506825&r1=506824&r2=506825
==============================================================================
---
portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/util/test/AbstractPrefsSupportedTestCase.java
(original)
+++
portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/util/test/AbstractPrefsSupportedTestCase.java
Mon Feb 12 18:47:07 2007
@@ -33,7 +33,7 @@
protected String[] getConfigurations()
{
return new String[]
- { "prefs.xml", "transaction.xml" };
+ { "prefs.xml", "transaction.xml", "cache.xml" };
}
protected String[] getBootConfigurations()
Modified:
portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferences.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferences.java?view=diff&rev=506825&r1=506824&r2=506825
==============================================================================
---
portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferences.java
(original)
+++
portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferences.java
Mon Feb 12 18:47:07 2007
@@ -38,7 +38,7 @@
public void setUp() throws Exception
{
super.setUp();
-
+
// Make sure we are starting with a clean slate
clearChildren(Preferences.userRoot());
clearChildren(Preferences.systemRoot());
@@ -289,6 +289,6 @@
protected String[] getConfigurations()
{
return new String[]
- { "prefs.xml", "transaction.xml" };
+ { "prefs.xml", "transaction.xml", "cache.xml" };
}
}
Modified:
portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesNoPropManager.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesNoPropManager.java?view=diff&rev=506825&r1=506824&r2=506825
==============================================================================
---
portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesNoPropManager.java
(original)
+++
portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesNoPropManager.java
Mon Feb 12 18:47:07 2007
@@ -81,6 +81,6 @@
protected String[] getConfigurations()
{
return new String[]
- { "prefs.xml", "transaction.xml" };
+ { "prefs.xml", "transaction.xml", "cache.xml" };
}
}
Modified:
portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesProvider.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesProvider.java?view=diff&rev=506825&r1=506824&r2=506825
==============================================================================
---
portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesProvider.java
(original)
+++
portals/jetspeed-2/trunk/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesProvider.java
Mon Feb 12 18:47:07 2007
@@ -129,6 +129,6 @@
*/
protected String[] getConfigurations()
{
- return new String[] { "prefs.xml", "transaction.xml" };
+ return new String[] { "prefs.xml", "transaction.xml", "cache.xml" };
}
}
Modified:
portals/jetspeed-2/trunk/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java?view=diff&rev=506825&r1=506824&r2=506825
==============================================================================
---
portals/jetspeed-2/trunk/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java
(original)
+++
portals/jetspeed-2/trunk/components/registry/src/test/org/apache/jetspeed/components/portletentity/TestPortletEntityDAO.java
Mon Feb 12 18:47:07 2007
@@ -292,6 +292,6 @@
protected String[] getConfigurations()
{
return new String[]
- { "transaction.xml", "registry-test.xml", "prefs.xml" };
+ { "transaction.xml", "registry-test.xml", "prefs.xml", "cache.xml" };
}
}
Modified:
portals/jetspeed-2/trunk/components/registry/src/test/org/apache/jetspeed/components/portletregistry/AbstractRegistryTest.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/registry/src/test/org/apache/jetspeed/components/portletregistry/AbstractRegistryTest.java?view=diff&rev=506825&r1=506824&r2=506825
==============================================================================
---
portals/jetspeed-2/trunk/components/registry/src/test/org/apache/jetspeed/components/portletregistry/AbstractRegistryTest.java
(original)
+++
portals/jetspeed-2/trunk/components/registry/src/test/org/apache/jetspeed/components/portletregistry/AbstractRegistryTest.java
Mon Feb 12 18:47:07 2007
@@ -202,7 +202,7 @@
protected String[] getConfigurations()
{
return new String[]
- { "transaction.xml", "prefs.xml", "registry-test.xml" };
+ { "transaction.xml", "prefs.xml", "registry-test.xml", "cache.xml" };
}
}
Modified:
portals/jetspeed-2/trunk/components/registry/src/test/org/apache/jetspeed/components/portletregistry/TestPortletRegistryDAO.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/registry/src/test/org/apache/jetspeed/components/portletregistry/TestPortletRegistryDAO.java?view=diff&rev=506825&r1=506824&r2=506825
==============================================================================
---
portals/jetspeed-2/trunk/components/registry/src/test/org/apache/jetspeed/components/portletregistry/TestPortletRegistryDAO.java
(original)
+++
portals/jetspeed-2/trunk/components/registry/src/test/org/apache/jetspeed/components/portletregistry/TestPortletRegistryDAO.java
Mon Feb 12 18:47:07 2007
@@ -320,6 +320,6 @@
protected String[] getConfigurations()
{
return new String[]
- { "transaction.xml", "registry-test.xml", "prefs.xml" };
+ { "transaction.xml", "registry-test.xml", "prefs.xml", "cache.xml" };
}
}
Modified: portals/jetspeed-2/trunk/components/security/maven.xml
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/security/maven.xml?view=diff&rev=506825&r1=506824&r2=506825
==============================================================================
--- portals/jetspeed-2/trunk/components/security/maven.xml (original)
+++ portals/jetspeed-2/trunk/components/security/maven.xml Mon Feb 12 18:47:07
2007
@@ -18,6 +18,6 @@
<!-- Target of maven test:single test -->
<!-- <property name="testcase"
value="org.apache.jetspeed.security.spi.ldap.TestLdapUserSecurityHandler" /> -->
- <property name="testcase"
value="org.apache.jetspeed.security.TestPermissionManager" />
+ <property name="testcase"
value="org.apache.jetspeed.security.spi.TestUserSecurityHandler" />
</project>
Modified:
portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/TestUserSecurityHandler.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/TestUserSecurityHandler.java?view=diff&rev=506825&r1=506824&r2=506825
==============================================================================
---
portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/TestUserSecurityHandler.java
(original)
+++
portals/jetspeed-2/trunk/components/security/src/test/org/apache/jetspeed/security/spi/TestUserSecurityHandler.java
Mon Feb 12 18:47:07 2007
@@ -48,8 +48,8 @@
*/
public void tearDown() throws Exception
{
- super.tearDown();
destroyUsers();
+ super.tearDown();
}
/**
Modified: portals/jetspeed-2/trunk/etc/build.xml
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/etc/build.xml?view=diff&rev=506825&r1=506824&r2=506825
==============================================================================
--- portals/jetspeed-2/trunk/etc/build.xml (original)
+++ portals/jetspeed-2/trunk/etc/build.xml Mon Feb 12 18:47:07 2007
@@ -476,7 +476,8 @@
<include name="prefs.xml"/>
<include name="profiler.xml"/>
<include name="registry.xml"/>
- <include name="transaction.xml"/>
+ <include name="transaction.xml"/>
+ <include name="cache.xml" />
</fileset>
</copy>
<copy todir="${temp.assembly.dir}" overwrite="true" failonerror="true">
@@ -559,7 +560,7 @@
<pathelement
path="${org.apache.jetspeed.database.jdbc.drivers.path}"/>
<pathelement path="${basedir}/target/seed/classes"/>
</classpath>
- <arg line="-l DEBUG -I ${basedir}/target/seed/data/ -b
${assembly.dir}/boot/ -c ${assembly.dir}/ -dc
${org.apache.jetspeed.database.driver} -ds ${org.apache.jetspeed.database.url}
-du ${org.apache.jetspeed.database.user} -dp
${org.apache.jetspeed.database.password}"/>
+ <arg line="-l DEBUG -I ${basedir}/target/seed/data/ -a ${basedir} -b
${assembly.dir}/boot/ -c ${assembly.dir}/ -dc
${org.apache.jetspeed.database.driver} -ds ${org.apache.jetspeed.database.url}
-du ${org.apache.jetspeed.database.user} -dp
${org.apache.jetspeed.database.password}"/>
</java>
</target>
Modified: portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/cache.xml
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/cache.xml?view=diff&rev=506825&r1=506824&r2=506825
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/cache.xml (original)
+++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/cache.xml Mon Feb 12
18:47:07 2007
@@ -18,7 +18,9 @@
<beans>
<bean id="cacheManager"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
+ <!-- get it through the class path
<property name="configLocation"
value="${applicationRoot}/WEB-INF/conf/ehcache.xml"/>
+ -->
</bean>
<!-- Factory bean used to instantiate a EHCache with the specified name (and
corresponding
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]