You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by at...@apache.org on 2008/03/24 03:13:32 UTC
svn commit: r640285 - in /portals/jetspeed-2/portal/trunk: ./
components/jetspeed-cm/
components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/
components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/
components/jetspeed-portal/src/ma...
Author: ate
Date: Sun Mar 23 19:13:30 2008
New Revision: 640285
URL: http://svn.apache.org/viewvc?rev=640285&view=rev
Log:
Synchronizing JS2-800 with 2.2 trunk too, see https://issues.apache.org/jira/browse/JS2-800
Added:
portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhPortletWindowCache.java (with props)
portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestPortletWindowCache.java (with props)
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/HashMapWindowCache.java (with props)
portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/PortletWindowCache.java (with props)
Modified:
portals/jetspeed-2/portal/trunk/components/jetspeed-cm/pom.xml
portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java
portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java
portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhDecorationContentCacheImpl.java
portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheImpl.java
portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/ (props changed)
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletTrackingManagerImpl.java
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/ (props changed)
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/AbstractPortalContainerTestCase.java
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/window/TestWindows.java
portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/window/PortletWindowAccessor.java
portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/cache.xml
portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-spring.xml
portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/db-ojb/ehcache.xml
portals/jetspeed-2/portal/trunk/pom.xml
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/pom.xml?rev=640285&r1=640284&r2=640285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/pom.xml Sun Mar 23 19:13:30 2008
@@ -99,6 +99,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>jmock</groupId>
+ <artifactId>jmock-cglib</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>${org.apache.jetspeed.test.jdbc.driver.groupId}</groupId>
<artifactId>${org.apache.jetspeed.test.jdbc.driver.artifactId}</artifactId>
<version>${org.apache.jetspeed.test.jdbc.driver.version}</version>
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java?rev=640285&r1=640284&r2=640285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java Sun Mar 23 19:13:30 2008
@@ -41,7 +41,7 @@
private Map refList = Collections.synchronizedMap(new HashMap());
- public EhCacheDistributedImpl(Cache ehcache)
+ public EhCacheDistributedImpl(Ehcache ehcache)
{
super(ehcache);
RegisteredEventListeners listeners = ehcache
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java?rev=640285&r1=640284&r2=640285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java Sun Mar 23 19:13:30 2008
@@ -20,7 +20,7 @@
import java.util.ArrayList;
import java.util.List;
-import net.sf.ehcache.Cache;
+import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import org.apache.jetspeed.cache.CacheElement;
@@ -31,11 +31,11 @@
public class EhCacheImpl implements JetspeedCache
{
- protected Cache ehcache;
+ protected Ehcache ehcache;
protected List localListeners = new ArrayList();
protected List remoteListeners = new ArrayList();
- public EhCacheImpl(Cache ehcache)
+ public EhCacheImpl(Ehcache ehcache)
{
this.ehcache = ehcache;
}
@@ -73,8 +73,8 @@
public CacheElement createElement(Object key, Object content)
{
- if (!((key instanceof Serializable) && (content instanceof Serializable)))
- return null;
+ 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);
}
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhDecorationContentCacheImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhDecorationContentCacheImpl.java?rev=640285&r1=640284&r2=640285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhDecorationContentCacheImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhDecorationContentCacheImpl.java Sun Mar 23 19:13:30 2008
@@ -24,6 +24,7 @@
import java.util.StringTokenizer;
import net.sf.ehcache.Cache;
+import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import org.apache.jetspeed.cache.CacheElement;
@@ -33,10 +34,9 @@
import org.apache.jetspeed.cache.JetspeedCache;
import org.apache.jetspeed.cache.JetspeedCacheEventListener;
import org.apache.jetspeed.cache.JetspeedContentCache;
-import org.apache.jetspeed.cache.impl.JetspeedContentCacheKey;
import org.apache.jetspeed.decoration.Theme;
-import org.apache.jetspeed.request.RequestContext;
import org.apache.jetspeed.om.page.ContentPage;
+import org.apache.jetspeed.request.RequestContext;
/**
* Wrapper around actual cache implementation
@@ -50,7 +50,7 @@
JetspeedCache preferenceCache = null;
ContentCacheKeyGenerator keyGenerator = null;
- public EhDecorationContentCacheImpl(Cache ehcache, JetspeedCache preferenceCache, ContentCacheKeyGenerator keyGenerator)
+ public EhDecorationContentCacheImpl(Ehcache ehcache, JetspeedCache preferenceCache, ContentCacheKeyGenerator keyGenerator)
{
this(ehcache);
this.preferenceCache = preferenceCache;
@@ -58,14 +58,14 @@
preferenceCache.addEventListener(this,false); //only listen to remote events
}
- public EhDecorationContentCacheImpl(Cache ehcache, JetspeedCache preferenceCache)
+ public EhDecorationContentCacheImpl(Ehcache ehcache, JetspeedCache preferenceCache)
{
this(ehcache);
this.preferenceCache = preferenceCache;
preferenceCache.addEventListener(this,false); //only listen to remote events
}
- public EhDecorationContentCacheImpl(Cache ehcache)
+ public EhDecorationContentCacheImpl(Ehcache ehcache)
{
super(ehcache);
}
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheImpl.java?rev=640285&r1=640284&r2=640285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheImpl.java Sun Mar 23 19:13:30 2008
@@ -23,7 +23,7 @@
import java.util.Map;
import java.util.StringTokenizer;
-import net.sf.ehcache.Cache;
+import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
import org.apache.jetspeed.cache.CacheElement;
@@ -48,7 +48,7 @@
JetspeedCache preferenceCache = null;
ContentCacheKeyGenerator keyGenerator = null;
- public EhPortletContentCacheImpl(Cache ehcache, JetspeedCache preferenceCache, ContentCacheKeyGenerator keyGenerator)
+ public EhPortletContentCacheImpl(Ehcache ehcache, JetspeedCache preferenceCache, ContentCacheKeyGenerator keyGenerator)
{
this(ehcache);
this.preferenceCache = preferenceCache;
@@ -56,19 +56,19 @@
preferenceCache.addEventListener(this,false); //only listen to remote events
}
- public EhPortletContentCacheImpl(Cache ehcache, JetspeedCache preferenceCache)
+ public EhPortletContentCacheImpl(Ehcache ehcache, JetspeedCache preferenceCache)
{
this(ehcache);
this.preferenceCache = preferenceCache;
preferenceCache.addEventListener(this,false); //only listen to remote events
}
- public EhPortletContentCacheImpl(Cache ehcache)
+ public EhPortletContentCacheImpl(Ehcache ehcache)
{
super(ehcache);
}
- public EhPortletContentCacheImpl(Cache ehcache, ContentCacheKeyGenerator keyGenerator)
+ public EhPortletContentCacheImpl(Ehcache ehcache, ContentCacheKeyGenerator keyGenerator)
{
this(ehcache);
this.keyGenerator = keyGenerator;
Added: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhPortletWindowCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhPortletWindowCache.java?rev=640285&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhPortletWindowCache.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhPortletWindowCache.java Sun Mar 23 19:13:30 2008
@@ -0,0 +1,140 @@
+/*
+* 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.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import net.sf.ehcache.Ehcache;
+
+import org.apache.jetspeed.cache.CacheElement;
+import org.apache.jetspeed.cache.PortletWindowCache;
+import org.apache.pluto.om.entity.PortletEntity;
+import org.apache.pluto.om.window.PortletWindow;
+
+/**
+ * <p>
+ * EhPortletWindowCache
+ * </p>
+ * <p>
+ * Implementation of {@link PortletWindowCache} that is backed
+ * <a href="http://ehcache.sourceforge.net/">Ehcache</a>.
+ * </p>
+ * @author <a href="mailto:scott.t.weaver@gmail.com">Scott T. Weaver</a>
+ *
+ */
+public class EhPortletWindowCache extends EhCacheImpl implements PortletWindowCache {
+
+ /** Allows us to track {@link PortletWindow}s in cache by {@link PortletEntity#getId()}*/
+ private Map portletEntityIdToEntityid;
+
+
+ public EhPortletWindowCache(Ehcache ehcache)
+ {
+ super(ehcache);
+ portletEntityIdToEntityid = new HashMap();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.cache.impl.PortletWindowCache#getPortletWindow(java.lang.String)
+ */
+ public PortletWindow getPortletWindow(String windowId)
+ {
+ assert windowId != null;
+ CacheElement cacheElement = get(windowId);
+ if(cacheElement != null)
+ {
+ return (PortletWindow) cacheElement.getContent();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.cache.impl.PortletWindowCache#getPortletWindowByEntityId(java.lang.String)
+ */
+ public PortletWindow getPortletWindowByEntityId(String portletEntityId)
+ {
+ assert portletEntityId != null;
+ if(portletEntityIdToEntityid.containsKey(portletEntityId))
+ {
+ return (PortletWindow) getPortletWindow((String) portletEntityIdToEntityid.get(portletEntityId));
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.cache.impl.PortletWindowCache#putPortletWindow(org.apache.pluto.om.window.PortletWindow)
+ */
+ public void putPortletWindow(PortletWindow window)
+ {
+ assert window != null;
+ String windowId = window.getId().toString();
+ portletEntityIdToEntityid.put(window.getPortletEntity().getId().toString(), windowId);
+ put(createElement(windowId, window));
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.cache.impl.PortletWindowCache#removePortletWindow(java.lang.String)
+ */
+ public void removePortletWindow(String portletWindowId)
+ {
+ assert portletWindowId != null;
+ PortletWindow window = getPortletWindow(portletWindowId);
+ if(window != null)
+ {
+ portletEntityIdToEntityid.remove(window.getPortletEntity().getId().toString());
+ removeQuiet(portletWindowId);
+ }
+ }
+
+ public void removePortletWindowByPortletEntityId(String portletEntityId)
+ {
+ assert portletEntityId != null;
+ PortletWindow portletWindow = getPortletWindowByEntityId(portletEntityId);
+ if(portletWindow != null)
+ {
+ portletEntityIdToEntityid.remove(portletEntityId);
+ removeQuiet(portletWindow.getId().toString());
+ }
+ }
+
+ public Set getAllPortletWindows()
+ {
+ Iterator keys = ehcache.getKeys().iterator();
+ Set windows = new HashSet();
+ while(keys.hasNext())
+ {
+ String key = (String) keys.next();
+ PortletWindow window = getPortletWindow(key);
+ if(window != null)
+ {
+ windows.add(window);
+ }
+ }
+ return windows;
+ }
+
+}
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhPortletWindowCache.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhPortletWindowCache.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/main/java/org/apache/jetspeed/cache/impl/EhPortletWindowCache.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sun Mar 23 19:13:30 2008
@@ -1,2 +1,2 @@
-target
+target
surefire*.properties
Added: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestPortletWindowCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestPortletWindowCache.java?rev=640285&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestPortletWindowCache.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestPortletWindowCache.java Sun Mar 23 19:13:30 2008
@@ -0,0 +1,222 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import net.sf.ehcache.Ehcache;
+import net.sf.ehcache.Element;
+
+import org.apache.jetspeed.cache.impl.EhCacheImpl;
+import org.apache.jetspeed.cache.impl.EhPortletWindowCache;
+import org.apache.pluto.om.common.ObjectID;
+import org.apache.pluto.om.entity.PortletEntity;
+import org.apache.pluto.om.window.PortletWindow;
+import org.jmock.Mock;
+import org.jmock.cglib.MockObjectTestCase;
+import org.jmock.core.stub.VoidStub;
+
+
+
+/**
+ *
+ * Tests for {@link EhPortletWindowCache}.
+ *
+ * @author <a href="mailto:scott.t.weaver@gmail.com">Scott T. Weaver</a>
+ *
+ */
+public class TestPortletWindowCache extends MockObjectTestCase
+{
+ private static final String WINDOW_ID = "window1";
+ private static final String ENTITY_ID = "entity1";
+
+
+ private Mock cacheMock;
+ private Mock windowMock;
+ private Mock entityMock;
+ private Mock oidMock;
+ private Mock entityOidMock;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ cacheMock = mock(Ehcache.class);
+ windowMock = mock(SerializablePortletWindow.class);
+ entityMock = mock(PortletEntity.class);
+ oidMock = mock(ObjectID.class);
+ entityOidMock = (Mock) mock(ObjectID.class);
+ }
+
+ public void testSimplePutAndGet()
+ {
+
+ PortletWindow window = (PortletWindow) windowMock.proxy();
+ Element element = new Element(WINDOW_ID, window);
+ ObjectID oid = (ObjectID) oidMock.proxy();
+ ObjectID entityOid = (ObjectID) entityOidMock.proxy();
+ entityOidMock.expects(atLeastOnce()).method("toString").will(returnValue(ENTITY_ID));
+ oidMock.expects(atLeastOnce()).method("toString").will(returnValue(WINDOW_ID));
+ windowMock.expects(once()).method("getId").withNoArguments().will(returnValue(oid));
+ windowMock.expects(once()).method("getPortletEntity").withNoArguments().will(returnValue(entityMock.proxy()));
+ entityMock.expects(once()).method("getId").withNoArguments().will(returnValue(entityOid));
+ cacheMock.expects(once()).method("put").with(eq(element));
+ cacheMock.expects(atLeastOnce()).method("get").with(eq(WINDOW_ID)).will(returnValue(element));
+
+
+ Ehcache cache = (Ehcache) cacheMock.proxy();
+ PortletWindowCache windowCache = new EhPortletWindowCache(cache);
+ windowCache.putPortletWindow(window);
+
+ assertNotNull(windowCache.getPortletWindow(WINDOW_ID));
+ assertEquals(windowCache.getPortletWindow(WINDOW_ID), window);
+
+ verify();
+ }
+
+ public void testGetByPortletEntity()
+ {
+
+ SerializablePortletWindow window = (SerializablePortletWindow) windowMock.proxy();
+ Element element = new Element(WINDOW_ID, window);
+
+ ObjectID oid = (ObjectID) oidMock.proxy();
+ oidMock.expects(atLeastOnce()).method("toString").will(returnValue(WINDOW_ID));
+ ObjectID entityOid = (ObjectID) entityOidMock.proxy();
+ entityOidMock.expects(atLeastOnce()).method("toString").will(returnValue(ENTITY_ID));
+ cacheMock.expects(once()).method("put").with(eq(element));
+ cacheMock.expects(once()).method("get").with(eq(WINDOW_ID)).will(returnValue(element));
+ windowMock.expects(once()).method("getId").withNoArguments().will(returnValue(oid));
+ windowMock.expects(once()).method("getPortletEntity").withNoArguments().will(returnValue(entityMock.proxy()));
+ entityMock.expects(once()).method("getId").withNoArguments().will(returnValue(entityOid));
+
+ Ehcache cache = (Ehcache) cacheMock.proxy();
+ PortletWindowCache windowCache = new EhPortletWindowCache(cache);
+ windowCache.putPortletWindow(window);
+
+ PortletWindow fromCache = windowCache.getPortletWindowByEntityId(ENTITY_ID);
+ assertNotNull(fromCache);
+
+ verify();
+ }
+
+ public void testRemove()
+ {
+ SerializablePortletWindow window = (SerializablePortletWindow) windowMock.proxy();
+ Element element = new Element(WINDOW_ID, window);
+
+ ObjectID oid = (ObjectID) oidMock.proxy();
+ oidMock.expects(atLeastOnce()).method("toString").will(returnValue(WINDOW_ID));
+
+ ObjectID entityOid = (ObjectID)entityOidMock.proxy();
+ entityOidMock.expects(atLeastOnce()).method("toString").will(returnValue(ENTITY_ID));
+
+ cacheMock.expects(once()).method("put").with(eq(element));
+ cacheMock.expects(exactly(2)).method("get").with(eq(WINDOW_ID)).will(returnValue(element));
+ windowMock.expects(once()).method("getId").withNoArguments().will(returnValue(oid));
+ windowMock.expects(exactly(2)).method("getPortletEntity").withNoArguments().will(returnValue(entityMock.proxy()));
+ entityMock.expects(exactly(2)).method("getId").withNoArguments().will(returnValue(entityOid));
+
+
+ cacheMock.expects(once()).method("removeQuiet").with(eq(WINDOW_ID)).will(returnValue(true));
+
+
+ Ehcache cache = (Ehcache) cacheMock.proxy();
+ PortletWindowCache windowCache = new EhPortletWindowCache(cache);
+ windowCache.putPortletWindow(window);
+
+ windowCache.removePortletWindow(WINDOW_ID);
+ assertNull(windowCache.getPortletWindowByEntityId(ENTITY_ID));
+
+ verify();
+ }
+
+ public void testRemoveByEntityId()
+ {
+ SerializablePortletWindow window = (SerializablePortletWindow) windowMock.proxy();
+ Element element = new Element(WINDOW_ID, window);
+
+ ObjectID oid = (ObjectID) oidMock.proxy();
+ oidMock.expects(atLeastOnce()).method("toString").will(returnValue(WINDOW_ID));
+
+ ObjectID entityOid = (ObjectID) entityOidMock.proxy();
+ entityOidMock.expects(atLeastOnce()).method("toString").will(returnValue(ENTITY_ID));
+
+ cacheMock.expects(once()).method("put").with(eq(element));
+ cacheMock.expects(exactly(3)).method("get").with(eq(WINDOW_ID)).will(onConsecutiveCalls(returnValue(element), returnValue(element), new VoidStub()));
+ windowMock.expects(exactly(2)).method("getId").withNoArguments().will(returnValue(oid));
+ windowMock.expects(once()).method("getPortletEntity").withNoArguments().will(returnValue(entityMock.proxy()));
+ entityMock.expects(once()).method("getId").withNoArguments().will(returnValue(entityOid));
+
+
+ cacheMock.expects(atLeastOnce()).method("removeQuiet").with(eq(WINDOW_ID)).will(returnValue(true));
+
+
+ Ehcache cache = (Ehcache) cacheMock.proxy();
+ PortletWindowCache windowCache = new EhPortletWindowCache(cache);
+ windowCache.putPortletWindow(window);
+
+ windowCache.removePortletWindowByPortletEntityId(ENTITY_ID);
+ assertNull(windowCache.getPortletWindow(WINDOW_ID));
+
+ verify();
+ }
+
+ public void testGetAllPortletWindows()
+ {
+ PortletWindow window = (PortletWindow) windowMock.proxy();
+ PortletWindow window2 = (PortletWindow) mock(SerializablePortletWindow.class).proxy();
+ PortletWindow window3 = (PortletWindow) mock(SerializablePortletWindow.class).proxy();
+
+ List keys = Arrays.asList(new String[] {WINDOW_ID, "window2", "window3"});
+
+ cacheMock.expects(once()).method("getKeys").withNoArguments().will(returnValue(keys));
+ cacheMock.expects(once()).method("get").with(eq(WINDOW_ID)).will(returnValue(new Element(WINDOW_ID, window)));
+ cacheMock.expects(once()).method("get").with(eq("window2")).will(returnValue(new Element("window2", window2)));
+ cacheMock.expects(once()).method("get").with(eq("window3")).will(returnValue(new Element("window3", window3)));
+
+ PortletWindowCache windowCache = new EhPortletWindowCache((Ehcache) cacheMock.proxy());
+
+ Set allPortletWindows = windowCache.getAllPortletWindows();
+ assertNotNull(allPortletWindows);
+ assertEquals(3, allPortletWindows.size());
+ }
+
+ public void testUnexpected()
+ {
+// PortletWindowCache windowCache = new EhPortletWindowCache((Ehcache) cacheMock.proxy());
+// cacheMock.proxy();
+// windowCache.getPortletWindow(null);
+// verify();
+ }
+
+ /**
+ * We need this class to test the cache as the {@link EhCacheImpl} object only
+ * allows {@link Serializable} objects to be cached.
+ *
+ * @author <a href="mailto:scott.t.weaver@gmail.com">Scott T. Weaver</a>
+ *
+ */
+ private interface SerializablePortletWindow extends PortletWindow, Serializable
+ {
+
+ }
+
+
+}
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestPortletWindowCache.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestPortletWindowCache.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestPortletWindowCache.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletTrackingManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletTrackingManagerImpl.java?rev=640285&r1=640284&r2=640285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletTrackingManagerImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/aggregator/impl/PortletTrackingManagerImpl.java Sun Mar 23 19:13:30 2008
@@ -131,8 +131,7 @@
Iterator windows = this.windowAccessor.getPortletWindows().iterator();
while (windows.hasNext())
{
- Map.Entry entry = (Map.Entry)windows.next();
- PortletWindow window = (PortletWindow)entry.getValue();
+ PortletWindow window = (PortletWindow)windows.next();
PortletDefinitionComposite pd = (PortletDefinitionComposite)window.getPortletEntity().getPortletDefinition();
for (int ix = 0; ix < fullPortletNames.size(); ix++)
{
@@ -150,8 +149,7 @@
Iterator windows = this.windowAccessor.getPortletWindows().iterator();
while (windows.hasNext())
{
- Map.Entry entry = (Map.Entry)windows.next();
- PortletWindow window = (PortletWindow)entry.getValue();
+ PortletWindow window = (PortletWindow)windows.next();
PortletDefinitionComposite pd = (PortletDefinitionComposite)window.getPortletEntity().getPortletDefinition();
if (pd.getUniqueName().equals(fullPortletName) && isOutOfService(window))
{
@@ -167,8 +165,7 @@
Iterator windows = this.windowAccessor.getPortletWindows().iterator();
while (windows.hasNext())
{
- Map.Entry entry = (Map.Entry)windows.next();
- PortletWindow window = (PortletWindow)entry.getValue();
+ PortletWindow window = (PortletWindow)windows.next();
if (isOutOfService(window))
{
outs.add(window);
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java?rev=640285&r1=640284&r2=640285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java Sun Mar 23 19:13:30 2008
@@ -16,15 +16,12 @@
*/
package org.apache.jetspeed.container.window.impl;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.Iterator;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.cache.PortletWindowCache;
import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
import org.apache.jetspeed.components.portletentity.PortletEntityNotGeneratedException;
import org.apache.jetspeed.components.portletentity.PortletEntityNotStoredException;
@@ -55,27 +52,33 @@
{
protected final static Log log = LogFactory.getLog(PortletWindowAccessorImpl.class);
- private Map windows = Collections.synchronizedMap(new HashMap());
+ //private Map windows = Collections.synchronizedMap(new HashMap());
private PortletEntityAccessComponent entityAccessor;
private PortletFactory portletFactory;
private boolean validateWindows = false;
+ private PortletWindowCache portletWindowCache;
+
- public PortletWindowAccessorImpl(PortletEntityAccessComponent entityAccessor, PortletFactory portletFactory, boolean validateWindows)
+ public PortletWindowAccessorImpl(PortletEntityAccessComponent entityAccessor, PortletFactory portletFactory, PortletWindowCache portletWindowCache, boolean validateWindows)
{
this.entityAccessor = entityAccessor;
this.portletFactory = portletFactory;
this.validateWindows = validateWindows;
+ this.portletWindowCache = portletWindowCache;
+
}
public PortletWindowAccessorImpl(PortletEntityAccessComponent entityAccessor,
PortletFactory portletFactory,
- PortletRegistry registry,
+ PortletRegistry registry,
+ PortletWindowCache portletWindowCache,
boolean validateWindows)
{
this.entityAccessor = entityAccessor;
this.portletFactory = portletFactory;
this.validateWindows = validateWindows;
+ this.portletWindowCache = portletWindowCache;
registry.addRegistryListener(this);
}
@@ -99,7 +102,8 @@
window.setPortletEntity(entity);
if ( isValidPortletEntity(entity))
{
- windows.put(windowId, window);
+ // windows.put(windowId, window);
+ portletWindowCache.putPortletWindow(window);
}
return window;
}
@@ -245,7 +249,7 @@
if ( !temporaryWindow )
{
- windows.put(fragment.getId(), portletWindow);
+ portletWindowCache.putPortletWindow(portletWindow);
}
return portletWindow;
@@ -254,32 +258,35 @@
public void removeWindows(PortletEntity portletEntity)
{
- List tmpWindows = new ArrayList(windows.entrySet());
- for(int i = 0; i < tmpWindows.size(); i++)
- {
- PortletWindow window = (PortletWindow)((Map.Entry)tmpWindows.get(i)).getValue();
- if (portletEntity.getId().equals(window.getPortletEntity().getId()))
- {
- removeWindow(window);
- }
- }
- tmpWindows.clear();
+// List tmpWindows = new ArrayList(windows.entrySet());
+// for(int i = 0; i < tmpWindows.size(); i++)
+// {
+// PortletWindow window = (PortletWindow)((Map.Entry)tmpWindows.get(i)).getValue();
+// if (portletEntity.getId().equals(window.getPortletEntity().getId()))
+// {
+// removeWindow(window);
+// }
+// }
+// tmpWindows.clear();
+//
+ portletWindowCache.removePortletWindowByPortletEntityId(portletEntity.getId().toString());
}
public void removeWindow(PortletWindow window)
{
- windows.remove(window.getId().toString());
+ // windows.remove(window.getId().toString());
+ portletWindowCache.removePortletWindow(window.getId().toString());
}
private PortletWindow getWindowFromCache(ContentFragment fragment)
{
- return (PortletWindow)windows.get(fragment.getId());
+ return portletWindowCache.getPortletWindow(fragment.getId());
}
private PortletWindow getWindowFromCache(String id)
{
- return (PortletWindow)windows.get(id);
+ return portletWindowCache.getPortletWindow(id);
}
private boolean checkPortletWindowEntity(PortletWindow window)
@@ -303,43 +310,76 @@
public Set getPortletWindows()
{
- return this.windows.entrySet();
+ return portletWindowCache.getAllPortletWindows();
}
protected void removeForPortletDefinition(PortletDefinitionComposite def)
{
- List tmpWindows = new ArrayList(windows.entrySet());
- for (int i = 0; i < tmpWindows.size(); i++)
+// List tmpWindows = new ArrayList(windows.entrySet());
+// for (int i = 0; i < tmpWindows.size(); i++)
+// {
+// PortletWindow window = (PortletWindow)((Map.Entry)tmpWindows.get(i)).getValue();
+// PortletDefinitionComposite windowDef = (PortletDefinitionComposite)window.getPortletEntity().getPortletDefinition();
+// if(def != null && windowDef != null && def.getUniqueName() != null && def.getUniqueName().equals(windowDef.getUniqueName()))
+// {
+// removeWindow(window);
+// }
+// }
+// tmpWindows.clear();
+// if (def != null)
+// portletFactory.updatePortletConfig(def);
+
+
+ Iterator windows = getPortletWindows().iterator();
+ while(windows.hasNext())
{
- PortletWindow window = (PortletWindow)((Map.Entry)tmpWindows.get(i)).getValue();
- PortletDefinitionComposite windowDef = (PortletDefinitionComposite)window.getPortletEntity().getPortletDefinition();
+ PortletWindow window = (PortletWindow) windows.next();
+ PortletDefinitionComposite windowDef = (PortletDefinitionComposite)window.getPortletEntity().getPortletDefinition();
if(def != null && windowDef != null && def.getUniqueName() != null && def.getUniqueName().equals(windowDef.getUniqueName()))
{
removeWindow(window);
}
- }
- tmpWindows.clear();
+ }
+
if (def != null)
portletFactory.updatePortletConfig(def);
}
protected void removeForPortletApplication(MutablePortletApplication app)
{
- List tmpWindows = new ArrayList(windows.entrySet());
- for (int i = 0; i < tmpWindows.size(); i++)
+// List tmpWindows = new ArrayList(windows.entrySet());
+// for (int i = 0; i < tmpWindows.size(); i++)
+// {
+// PortletWindow window = (PortletWindow)((Map.Entry)tmpWindows.get(i)).getValue();
+// PortletDefinitionComposite pd = (PortletDefinitionComposite)window.getPortletEntity().getPortletDefinition();
+// if (pd != null)
+// {
+// MutablePortletApplication windowApp = (MutablePortletApplication)pd.getPortletApplicationDefinition();
+// if (app.getName().equals(windowApp.getName()))
+// {
+// removeWindow(window);
+// }
+// }
+// }
+// tmpWindows.clear();
+
+ Iterator windows = getPortletWindows().iterator();
+ while(windows.hasNext())
{
- PortletWindow window = (PortletWindow)((Map.Entry)tmpWindows.get(i)).getValue();
- PortletDefinitionComposite pd = (PortletDefinitionComposite)window.getPortletEntity().getPortletDefinition();
- if (pd != null)
- {
- MutablePortletApplication windowApp = (MutablePortletApplication)pd.getPortletApplicationDefinition();
- if (app.getName().equals(windowApp.getName()))
- {
- removeWindow(window);
- }
- }
- }
- tmpWindows.clear();
+ PortletWindow window = (PortletWindow) windows.next();
+ PortletDefinitionComposite pd = (PortletDefinitionComposite)window.getPortletEntity().getPortletDefinition();
+ if (pd != null)
+ {
+ MutablePortletApplication windowApp = (MutablePortletApplication)pd.getPortletApplicationDefinition();
+ if (app.getName().equals(windowApp.getName()))
+ {
+ removeWindow(window);
+ }
+ }
+ }
+
+
+
}
public void applicationRemoved(MutablePortletApplication app)
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sun Mar 23 19:13:30 2008
@@ -1,2 +1,2 @@
-target
+target
surefire*.properties
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/AbstractPortalContainerTestCase.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/AbstractPortalContainerTestCase.java?rev=640285&r1=640284&r2=640285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/AbstractPortalContainerTestCase.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/AbstractPortalContainerTestCase.java Sun Mar 23 19:13:30 2008
@@ -22,20 +22,26 @@
import org.apache.pluto.PortletContainer;
/**
- * @author <a href="mailto:sweaver@einnovation.com">Scott T. Weaver</a>
- *
+ * @author <a href="mailto:scott.t.weaver@gmail.com">Scott T. Weaver</a>
+ *
*/
public class AbstractPortalContainerTestCase extends AbstractRequestContextTestCase
{
protected PortletWindowAccessor windowAccessor;
+
protected PortletContainer portletContainer;
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception
{
super.setUp();
- windowAccessor = new PortletWindowAccessorImpl(entityAccess,PortletFactoryMock.instance,true);
+ windowAccessor = new PortletWindowAccessorImpl(entityAccess,
+ PortletFactoryMock.instance,
+ new HashMapWindowCache(),
+ true);
}
}
Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/HashMapWindowCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/HashMapWindowCache.java?rev=640285&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/HashMapWindowCache.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/HashMapWindowCache.java Sun Mar 23 19:13:30 2008
@@ -0,0 +1,100 @@
+/*
+ * 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;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.apache.jetspeed.cache.PortletWindowCache;
+import org.apache.pluto.om.window.PortletWindow;
+
+/**
+ * This implementation of {@link PortletWindowCache} is to be used ONLY for testing purposes.
+ *
+ * @author <a href="mailto:scott.t.weaver@gmail.com">Scott T. Weaver</a>
+ *
+ */
+public class HashMapWindowCache implements PortletWindowCache
+{
+
+
+ private Map portletEntityToWindow = new HashMap();
+ private Map windows = new HashMap();
+
+ public Set getAllPortletWindows()
+ {
+ Set windowSet = new HashSet();
+
+ Iterator itr = windows.entrySet().iterator();
+ while(itr.hasNext())
+ {
+ Map.Entry entry = (Entry) itr.next();
+ windowSet.add((PortletWindow)entry.getValue());
+ }
+
+ return windowSet;
+ }
+
+ public PortletWindow getPortletWindow(String windowId)
+ {
+ return (PortletWindow) windows.get(windowId);
+ }
+
+ public PortletWindow getPortletWindowByEntityId(String portletEntityId)
+ {
+ if(portletEntityToWindow.containsKey(portletEntityId))
+ {
+ return (PortletWindow) windows.get((String) portletEntityToWindow.get(portletEntityId));
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void putPortletWindow(PortletWindow window)
+ {
+ windows.put(window.getId().toString(), window);
+ portletEntityToWindow.put(window.getPortletEntity().getId().toString(), window.getId().toString());
+
+ }
+
+ public void removePortletWindow(String windowId)
+ {
+ PortletWindow window = (PortletWindow) windows.get(windowId);
+ if(window != null)
+ {
+ windows.remove(windowId);
+ portletEntityToWindow.remove(window.getPortletEntity().getId().toString());
+ }
+
+ }
+
+ public void removePortletWindowByPortletEntityId(String portletEntityId)
+ {
+ PortletWindow window = getPortletWindowByEntityId(portletEntityId);
+ if(window != null)
+ {
+ removePortletWindow(window.getId().toString());
+ }
+
+ }
+}
\ No newline at end of file
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/HashMapWindowCache.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/HashMapWindowCache.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/HashMapWindowCache.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/window/TestWindows.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/window/TestWindows.java?rev=640285&r1=640284&r2=640285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/window/TestWindows.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/test/java/org/apache/jetspeed/window/TestWindows.java Sun Mar 23 19:13:30 2008
@@ -25,6 +25,7 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.apache.jetspeed.HashMapWindowCache;
import org.apache.jetspeed.PortletFactoryMock;
import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
import org.apache.jetspeed.container.window.PortletWindowAccessor;
@@ -33,6 +34,7 @@
import org.apache.jetspeed.om.page.ContentFragment;
import org.apache.jetspeed.om.page.Fragment;
import org.apache.jetspeed.om.page.ContentFragmentImpl;
+import org.apache.jetspeed.util.JetspeedObjectID;
import org.apache.pluto.om.window.PortletWindow;
import org.apache.pluto.om.window.PortletWindowList;
import org.apache.pluto.om.window.PortletWindowListCtrl;
@@ -77,7 +79,7 @@
fragMock = new Mock(Fragment.class);
entityMock = new Mock(MutablePortletEntity.class);
windowListMock = new Mock(CompositeWindowList.class);
- windowAccess = new PortletWindowAccessorImpl((PortletEntityAccessComponent) entityAccessMock.proxy(), PortletFactoryMock.instance,true);
+ windowAccess = new PortletWindowAccessorImpl((PortletEntityAccessComponent) entityAccessMock.proxy(), PortletFactoryMock.instance, new HashMapWindowCache(),true);
}
public void testWindowAccess() throws Exception
@@ -92,6 +94,8 @@
.will(new ReturnStub("frag1"));
entityMock.expects(new InvokeAtLeastOnceMatcher()).method("getPortletWindowList").withNoArguments().will(
new ReturnStub(windowList));
+ entityMock.expects(new InvokeAtLeastOnceMatcher()).method("getId").withNoArguments().will(
+ new ReturnStub(new JetspeedObjectID("entity1")));
windowListMock.expects(new InvokeCountMatcher(4)).method("add").withAnyArguments().will(
new ListAppendStub(windows));
Added: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/PortletWindowCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/PortletWindowCache.java?rev=640285&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/PortletWindowCache.java (added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/PortletWindowCache.java Sun Mar 23 19:13:30 2008
@@ -0,0 +1,88 @@
+/*
+ * 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;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.pluto.om.entity.PortletEntity;
+import org.apache.pluto.om.window.PortletWindow;
+
+/**
+ * {@link org.apache.jetspeed.cache.impl.PortletWindowCache} is an abstraction of a caching mechanism for use
+ * within {@link org.apache.jetspeed.container.window.impl.PortletWindowAccessorImpl}.
+ *
+ * @author <a href="mailto:scott.t.weaver@gmail.com">Scott T. Weaver</a>
+ * @see PortletWindowAccessorImpl
+ * @see EhPortletWindowCache
+ *
+ */
+public interface PortletWindowCache
+{
+ /**
+ * Gets a {@link PortletWindow} from the cache.
+ *
+ * @param windowId Id of the window to get from the cache.
+ * @return {@link PortletWindow} whose <code>id</code> to
+ * {@link PortletWindow#getId()} or <code>null</code> if no window exists that matches
+ * <code>windowId</code>.
+ */
+ PortletWindow getPortletWindow(String windowId);
+
+ /**
+ * Gets a {@link PortletWindow} from the cache whose {@link PortletEntity}'s ({@link PortletWindow#getPortletEntity()})
+ * equals <code>portletEntityId</code>.
+ *
+ * @param portletEntityId id of {@link PortletEntity} whose window want want to retrieve from cache.
+ * @return {@link PortletWindow} whose {@link PortletEntity}'s id equals <code>portletEntityId</code>
+ * or <code>null</code> if no windows exists in the cache that match said criteria.
+ */
+ PortletWindow getPortletWindowByEntityId(String portletEntityId);
+
+ /**
+ * Stores a {@link PortletWindow} in the cache using the {@link PortletWindow#getId()#toString()}
+ * as the key for the cache.
+ *
+ * @param window {@link PortletWindow} to put into the cache.
+ */
+ void putPortletWindow(PortletWindow window);
+
+ /**
+ * Removes a {@link PortletWindow} from cache using the <code>windowId</code>
+ * as the cache key.
+ *
+ * @param windowId Id of the {@link PortletWindow} we want to remove from the cache.
+ */
+ void removePortletWindow(String windowId);
+
+ /**
+ * Removes a {@link PortletWindow} from the cache whose {@link PortletEntity}'s id
+ * matches <code>portletEntityId</code>.
+ *
+ * @param portletEntityId id of the {@link PortletEntity} whose parent {@link PortletWindow}
+ * is to be removed from the cache.
+ */
+ void removePortletWindowByPortletEntityId(String portletEntityId);
+
+ /**
+ *
+ * @return {@link List} of all the {@link PortletWindow}s in the cache. If no cache
+ * entries exist an empty list is returned. Never returns <code>null</code>.
+ */
+ Set getAllPortletWindows();
+
+}
\ No newline at end of file
Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/PortletWindowCache.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/PortletWindowCache.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/cache/PortletWindowCache.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/window/PortletWindowAccessor.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/window/PortletWindowAccessor.java?rev=640285&r1=640284&r2=640285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/window/PortletWindowAccessor.java (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/container/window/PortletWindowAccessor.java Sun Mar 23 19:13:30 2008
@@ -107,9 +107,10 @@
void removeWindow(PortletWindow window);
/**
- * Get a list of all windows
+ * Gets a {@link Set} of currently available {@link PortletWindow}s within
+ * the current engine instance.
*
- * @return
+ * @return {@link Set} of {@link PortletWindow}s, never returns <code>null</code>
*/
Set getPortletWindows();
}
Modified: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/cache.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/cache.xml?rev=640285&r1=640284&r2=640285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/cache.xml (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/cache.xml Sun Mar 23 19:13:30 2008
@@ -89,6 +89,21 @@
</constructor-arg>
</bean>
+ <bean id="ehDecorationConfigurationCache"
+ class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+ <property name="cacheManager">
+ <ref local="cacheManager" />
+ </property>
+ <property name="cacheName" value="decorationConfigurationCache" />
+ </bean>
+
+ <bean id="decorationConfigurationCache"
+ class="org.apache.jetspeed.cache.impl.EhCacheImpl">
+ <constructor-arg>
+ <ref bean="ehDesktopContentCache" />
+ </constructor-arg>
+ </bean>
+
<bean id="ehPreferencesCache"
class="org.springframework.cache.ehcache.EhCacheFactoryBean">
<property name="cacheManager">
@@ -120,6 +135,14 @@
<property name="cacheName" value="portletApplicationNameCache" />
</bean>
+ <bean id="ehDesktopContentCache"
+ class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+ <property name="cacheManager">
+ <ref local="cacheManager" />
+ </property>
+ <property name="cacheName" value="desktopContentCache" />
+ </bean>
+
<bean id="portletApplicationOidCache"
class="org.apache.jetspeed.cache.impl.EhCacheImpl">
<constructor-arg>
@@ -134,6 +157,13 @@
</constructor-arg>
</bean>
+ <bean id="desktopContentCache"
+ class="org.apache.jetspeed.cache.impl.EhCacheImpl">
+ <constructor-arg>
+ <ref bean="ehDesktopContentCache" />
+ </constructor-arg>
+ </bean>
+
<bean id="ehPortletDefinitionOidCache"
class="org.springframework.cache.ehcache.EhCacheFactoryBean">
<property name="cacheManager">
@@ -181,6 +211,21 @@
<constructor-arg index="0">
<ref bean="ehActiveAuthenticationCache" />
</constructor-arg>
- </bean>
+ </bean>
+
+ <bean id="ehPortletWindowCache"
+ class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+ <property name="cacheManager">
+ <ref local="cacheManager" />
+ </property>
+ <property name="cacheName" value="portletWindowCache" />
+ </bean>
+
+ <bean id="portletWindowCache"
+ class="org.apache.jetspeed.cache.impl.EhPortletWindowCache">
+ <constructor-arg index="0">
+ <ref bean="ehPortletWindowCache" />
+ </constructor-arg>
+ </bean>
</beans>
Modified: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-spring.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-spring.xml?rev=640285&r1=640284&r2=640285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-spring.xml (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-spring.xml Sun Mar 23 19:13:30 2008
@@ -95,8 +95,11 @@
<constructor-arg index='2'>
<ref bean="org.apache.jetspeed.components.portletregistry.PortletRegistry" />
</constructor-arg>
+ <constructor-arg index='3'>
+ <ref bean="portletWindowCache" />
+ </constructor-arg>
<!-- enable window validation -->
- <constructor-arg type="boolean" index='3'>
+ <constructor-arg type="boolean" index='4'>
<value>false</value>
</constructor-arg>
</bean>
Modified: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/db-ojb/ehcache.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/db-ojb/ehcache.xml?rev=640285&r1=640284&r2=640285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/db-ojb/ehcache.xml (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/db-ojb/ehcache.xml Sun Mar 23 19:13:30 2008
@@ -417,8 +417,29 @@
replicateUpdates=false, replicateUpdatesViaCopy=false,
replicateRemovals=true"/>
-->
- </cache>
-
+ </cache>
+
+
+ <cache name="decorationConfigurationCache"
+ maxElementsInMemory="500"
+ maxElementsOnDisk="250"
+ eternal="false"
+ overflowToDisk="false"
+ timeToIdleSeconds="3600"
+ timeToLiveSeconds="3600"
+ memoryStoreEvictionPolicy="LFU">
+ </cache>
+
+ <cache name="desktopContentCache"
+ maxElementsInMemory="500"
+ maxElementsOnDisk="250"
+ eternal="false"
+ overflowToDisk="false"
+ timeToIdleSeconds="3600"
+ timeToLiveSeconds="3600"
+ memoryStoreEvictionPolicy="LFU">
+ </cache>
+
<!--
Sample distributed cache named sampleDistributedCache1.
This cache replicates using defaults.
@@ -479,7 +500,16 @@
timeToIdleSeconds="30"
timeToLiveSeconds="30"
memoryStoreEvictionPolicy="LFU"
- />
+ />
+
+ <cache name="portletWindowCache"
+ maxElementsInMemory="200"
+ maxElementsOnDisk="1000"
+ eternal="false"
+ overflowToDisk="false"
+ timeToIdleSeconds="28800"
+ timeToLiveSeconds="28800"
+ memoryStoreEvictionPolicy="LFU"/>
<cache name="decorationContentCache"
maxElementsInMemory="1000"
Modified: portals/jetspeed-2/portal/trunk/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/pom.xml?rev=640285&r1=640284&r2=640285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/pom.xml Sun Mar 23 19:13:30 2008
@@ -268,7 +268,8 @@
<!-- Build Dependency Version Properties -->
<ant.version>1.7</ant.version>
- <jmock.version>1.0.1</jmock.version>
+ <jmock.version>1.2.0</jmock.version>
+ <jmock-cglib.version>1.1.0</jmock-cglib.version>
<junit.version>3.8.1</junit.version>
<mockrunner.version>0.3.8</mockrunner.version>
<org.apache.maven.artifact.ant.version>2.0.5</org.apache.maven.artifact.ant.version>
@@ -813,6 +814,12 @@
<groupId>jmock</groupId>
<artifactId>jmock</artifactId>
<version>${jmock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jmock</groupId>
+ <artifactId>jmock-cglib</artifactId>
+ <version>${jmock-cglib.version}</version>
<scope>test</scope>
</dependency>
<dependency>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org