portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wea...@apache.org
Subject svn commit: r593209 - in /portals/jetspeed-2/branches/JETSPEED-2.1.3: components/cm/src/java/org/apache/jetspeed/cache/impl/ components/cm/src/test/org/apache/jetspeed/cache/ components/portal/src/java/org/apache/jetspeed/container/window/impl/ compone...
Date Thu, 08 Nov 2007 15:44:55 GMT
Author: weaver
Date: Thu Nov  8 07:44:51 2007
New Revision: 593209

URL: http://svn.apache.org/viewvc?rev=593209&view=rev
Log:
JS2-800.  Implementation of a PortletWindowCache for use within the PortletWindowAccessorImpl.

Added:
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletWindowCache.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/test/org/apache/jetspeed/cache/TestPortletWindowCache.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/HashMapWindowCache.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/cache/PortletWindowCache.java
Modified:
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhDecorationContentCacheImpl.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheImpl.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/AbstractPortalContainerTestCase.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/window/TestWindows.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/components/util/RegistrySupportedTestCase.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/etc/db-ojb/ehcache.xml
    portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/container/window/PortletWindowAccessor.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/cache.xml
    portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/jetspeed-spring.xml

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java?rev=593209&r1=593208&r2=593209&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java Thu Nov  8 07:44:51 2007
@@ -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/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java?rev=593209&r1=593208&r2=593209&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java Thu Nov  8 07:44:51 2007
@@ -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/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhDecorationContentCacheImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhDecorationContentCacheImpl.java?rev=593209&r1=593208&r2=593209&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhDecorationContentCacheImpl.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhDecorationContentCacheImpl.java Thu Nov  8 07:44:51 2007
@@ -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/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheImpl.java?rev=593209&r1=593208&r2=593209&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheImpl.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheImpl.java Thu Nov  8 07:44:51 2007
@@ -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/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletWindowCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletWindowCache.java?rev=593209&view=auto
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletWindowCache.java (added)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletWindowCache.java Thu Nov  8 07:44:51 2007
@@ -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;
+	}
+
+}

Added: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/test/org/apache/jetspeed/cache/TestPortletWindowCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/test/org/apache/jetspeed/cache/TestPortletWindowCache.java?rev=593209&view=auto
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/test/org/apache/jetspeed/cache/TestPortletWindowCache.java (added)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/cm/src/test/org/apache/jetspeed/cache/TestPortletWindowCache.java Thu Nov  8 07:44:51 2007
@@ -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
+    {
+        
+    }
+    
+
+}

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java?rev=593209&r1=593208&r2=593209&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java Thu Nov  8 07:44:51 2007
@@ -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)

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/AbstractPortalContainerTestCase.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/AbstractPortalContainerTestCase.java?rev=593209&r1=593208&r2=593209&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/AbstractPortalContainerTestCase.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/AbstractPortalContainerTestCase.java Thu Nov  8 07:44:51 2007
@@ -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/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/HashMapWindowCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/HashMapWindowCache.java?rev=593209&view=auto
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/HashMapWindowCache.java (added)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/HashMapWindowCache.java Thu Nov  8 07:44:51 2007
@@ -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

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/window/TestWindows.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/window/TestWindows.java?rev=593209&r1=593208&r2=593209&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/window/TestWindows.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/test/org/apache/jetspeed/window/TestWindows.java Thu Nov  8 07:44:51 2007
@@ -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));

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/components/util/RegistrySupportedTestCase.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/components/util/RegistrySupportedTestCase.java?rev=593209&r1=593208&r2=593209&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/components/util/RegistrySupportedTestCase.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/registry/src/java/org/apache/jetspeed/components/util/RegistrySupportedTestCase.java Thu Nov  8 07:44:51 2007
@@ -56,7 +56,7 @@
         List confList = new ArrayList(Arrays.asList(confs));
         confList.add("jetspeed-base.xml");
         confList.add("page-manager.xml");
-        confList.add("registry.xml");
+        confList.add("registry.xml");               
         return (String[]) confList.toArray(new String[1]);
     }
 }

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/etc/db-ojb/ehcache.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/etc/db-ojb/ehcache.xml?rev=593209&r1=593208&r2=593209&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/etc/db-ojb/ehcache.xml (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/etc/db-ojb/ehcache.xml Thu Nov  8 07:44:51 2007
@@ -489,6 +489,15 @@
            timeToIdleSeconds="30"
            timeToLiveSeconds="30"
            memoryStoreEvictionPolicy="LFU"
-            />
+            />
+   
+     <cache name="portletWindowCache"
+           maxElementsInMemory="200"
+           maxElementsOnDisk="1000"
+           eternal="false"
+           overflowToDisk="false"
+           timeToIdleSeconds="28800"
+           timeToLiveSeconds="28800"
+           memoryStoreEvictionPolicy="LFU"/>
 
 </ehcache>

Added: portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/cache/PortletWindowCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/cache/PortletWindowCache.java?rev=593209&view=auto
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/cache/PortletWindowCache.java (added)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/cache/PortletWindowCache.java Thu Nov  8 07:44:51 2007
@@ -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

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/container/window/PortletWindowAccessor.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/container/window/PortletWindowAccessor.java?rev=593209&r1=593208&r2=593209&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/container/window/PortletWindowAccessor.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/jetspeed-api/src/java/org/apache/jetspeed/container/window/PortletWindowAccessor.java Thu Nov  8 07:44:51 2007
@@ -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/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/cache.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/cache.xml?rev=593209&r1=593208&r2=593209&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/cache.xml (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/cache.xml Thu Nov  8 07:44:51 2007
@@ -196,6 +196,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/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/jetspeed-spring.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/jetspeed-spring.xml?rev=593209&r1=593208&r2=593209&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/jetspeed-spring.xml (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/jetspeed-spring.xml Thu Nov  8 07:44:51 2007
@@ -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>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message