portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r509904 [1/2] - in /portals/jetspeed-2/trunk: ./ commons/src/java/org/apache/jetspeed/container/ components/cm/src/java/org/apache/jetspeed/cache/impl/ components/portal/src/java/org/apache/jetspeed/container/window/impl/ components/portal/...
Date Wed, 21 Feb 2007 05:55:42 GMT
Author: taylor
Date: Tue Feb 20 21:55:40 2007
New Revision: 509904

URL: http://svn.apache.org/viewvc?view=rev&rev=509904
Log:
https://issues.apache.org/jira/browse/JS2-654
finishing up distributed cache work for 2.1
thanks to Hajo for working round the clock with me on this

Added:
    portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/RegistryCacheObjectWrapper.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/portletregistry/RegistryEventListener.java
Removed:
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/DistributedCacheElement.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/DistributedJetspeedCache.java
Modified:
    portals/jetspeed-2/trunk/.classpath
    portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/InternalPortletConfig.java
    portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedPortletConfig.java
    portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedElementImpl.java
    portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java
    portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java
    portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheElementImpl.java
    portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheImpl.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java
    portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/PortletFactoryMock.java
    portals/jetspeed-2/trunk/components/portlet-factory/src/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java
    portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java
    portals/jetspeed-2/trunk/components/registry/etc/assembly/registry-test.xml
    portals/jetspeed-2/trunk/components/registry/src/java/JETSPEED-INF/ojb/registry_repository.xml
    portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java
    portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java
    portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/RegistryApplicationCache.java
    portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/RegistryPortletCache.java
    portals/jetspeed-2/trunk/etc/db-ojb/ehcache.xml
    portals/jetspeed-2/trunk/etc/registration/assembly/registry.xml
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/CacheElement.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/JetspeedCache.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/JetspeedCacheEventListener.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/factory/PortletFactory.java
    portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/cache.xml
    portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-spring.xml
    portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/registry.xml

Modified: portals/jetspeed-2/trunk/.classpath
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/.classpath?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/.classpath (original)
+++ portals/jetspeed-2/trunk/.classpath Tue Feb 20 21:55:40 2007
@@ -120,5 +120,6 @@
 	<classpathentry kind="var" path="MAVEN_REPO/commons-betwixt/jars/commons-betwixt-20061115.jar"/>
 	<classpathentry kind="var" path="MAVEN_REPO/ant/jars/ant-1.6.5.jar"/>
 	<classpathentry kind="var" path="MAVEN_REPO/ehcache/jars/ehcache-1.2.4.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/pluto"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/InternalPortletConfig.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/InternalPortletConfig.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/InternalPortletConfig.java (original)
+++ portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/InternalPortletConfig.java Tue Feb 20 21:55:40 2007
@@ -26,6 +26,6 @@
  */
 public interface InternalPortletConfig
 {
-     public PortletDefinition getPortletDefinition();
-    
+     PortletDefinition getPortletDefinition();
+     void setPortletDefinition(PortletDefinition pd);
 }

Modified: portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedPortletConfig.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedPortletConfig.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedPortletConfig.java (original)
+++ portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedPortletConfig.java Tue Feb 20 21:55:40 2007
@@ -116,6 +116,11 @@
 
     }
 
+    public void setPortletDefinition(PortletDefinition pd)
+    {
+        this.portletDefinition = pd;        
+    }
+    
     //  internal portlet config implementation
     public PortletDefinition getPortletDefinition()
     {

Modified: portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedElementImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedElementImpl.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedElementImpl.java (original)
+++ portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedElementImpl.java Tue Feb 20 21:55:40 2007
@@ -19,76 +19,27 @@
 
 import net.sf.ehcache.Element;
 
-import org.apache.jetspeed.cache.DistributedCacheElement;
+import org.apache.jetspeed.cache.CacheElement;
 import org.apache.jetspeed.cache.DistributedCacheObject;
 
 
-public class EhCacheDistributedElementImpl implements DistributedCacheElement
+public class EhCacheDistributedElementImpl extends EhCacheElementImpl 
 {
-	Element element;
-	
 	public EhCacheDistributedElementImpl(Element element)
     {
-        this.element = element;
+        super(element);
     }
 
 	public EhCacheDistributedElementImpl(Serializable key, DistributedCacheObject value)
     {
-        this.element = new Element(key,value);
+		super(key, value);
         
     }
-
-
-	public Object getKey()
-	    {
-	        return element.getObjectKey();
-	    }
 	    
-	    
-	    public DistributedCacheObject getContent()
-	    {
-	        return (DistributedCacheObject)element.getObjectValue();
-	    }
-
-	    public int getTimeToIdleSeconds()
-	    {
-	        return element.getTimeToIdle();
-	    }
-
-	    public int getTimeToLiveSeconds()
-	    {
-	        return element.getTimeToLive();
-	    }
-
-	    public boolean isEternal()
-	    {
-	        return element.isEternal();
-	    }
-
-	    public Element getImplElement()
-	    {
-	        return element;
-	    }
-
-	    public void setEternal(boolean eternal)
-	    {
-	        element.setEternal(eternal);
-	    }
-
-	    public void setTimeToIdleSeconds(int timeToIdle)
-	    {
-	        element.setTimeToIdle(timeToIdle);
-	    }
-
-	    public void setTimeToLiveSeconds(int timeToLive)
-	    {
-	        element.setTimeToLive(timeToLive);
-	    }
-	    
-	    public void notifyChange(int action)
-	    {
-	    	getContent().notifyChange(action);
-	    }
+    public void notifyChange(int action)
+    {
+    	((DistributedCacheObject)getContent()).notifyChange(action);
+    }
 
 	    
 }

Modified: portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java (original)
+++ portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheDistributedImpl.java Tue Feb 20 21:55:40 2007
@@ -19,6 +19,7 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -29,27 +30,34 @@
 import net.sf.ehcache.event.CacheEventListener;
 import net.sf.ehcache.event.RegisteredEventListeners;
 
-import org.apache.jetspeed.cache.DistributedCacheElement;
+import org.apache.jetspeed.cache.CacheElement;
 import org.apache.jetspeed.cache.DistributedCacheObject;
-import org.apache.jetspeed.cache.DistributedJetspeedCache;
+import org.apache.jetspeed.cache.JetspeedCache;
 import org.apache.jetspeed.cache.JetspeedCacheEventListener;
 
-public class EhCacheDistributedImpl implements DistributedJetspeedCache, CacheEventListener
+public class EhCacheDistributedImpl extends EhCacheImpl implements JetspeedCache, CacheEventListener
 {
-	private Cache ehcache;
+
+
 	private Map refList = Collections.synchronizedMap(new HashMap());
-    protected List listeners = new ArrayList();
+
 
 	public EhCacheDistributedImpl(Cache ehcache)
 	{
-		this.ehcache = ehcache;
+		super(ehcache);
 		RegisteredEventListeners listeners = ehcache
 				.getCacheEventNotificationService();
 		listeners.registerListener(this);
 
 	}
 
-	public DistributedCacheElement get(Serializable key)
+	public CacheElement get(Object key)
+	{
+		return get((Serializable)key);
+	}
+
+
+	public CacheElement get(Serializable key)
 	{
 		Element element = ehcache.get(key);
 		if (element == null)
@@ -57,18 +65,12 @@
 		return new EhCacheDistributedElementImpl(element);
 	}
 
-	public void clear()
-	{
-		ehcache.removeAll();
-	}
-	public int getTimeToIdleSeconds()
-	{
-		return (int) ehcache.getTimeToIdleSeconds();
-	}
 
-	public int getTimeToLiveSeconds()
+	public boolean isKeyInCache(Object key)
 	{
-		return (int) ehcache.getTimeToLiveSeconds();
+		if ((key == null) || (!(key instanceof Serializable)))
+			return false;
+		return ehcache.isKeyInCache((Serializable)key);
 	}
 
 	public boolean isKeyInCache(Serializable key)
@@ -76,25 +78,40 @@
 		return ehcache.isKeyInCache(key);
 	}
 
-	public void put(DistributedCacheElement element)
+	public void put(CacheElement element)
 	{
 		EhCacheDistributedElementImpl impl = (EhCacheDistributedElementImpl) element;
 		ehcache.put(impl.getImplElement());
 		refList.put(impl.getKey(), impl);
+		notifyListeners(true, CacheElement.ActionAdded,impl.getKey(),impl.getContent());
 	}
 
-	public DistributedCacheElement createElement(Serializable key, DistributedCacheObject content)
+	public CacheElement createElement(Object key, Object content)
+	{
+		return new EhCacheDistributedElementImpl((Serializable)key, (DistributedCacheObject)content);
+	}
+
+	public CacheElement createElement(Serializable key, DistributedCacheObject content)
 	{
 		return new EhCacheDistributedElementImpl(key, content);
 	}
 
+
+	public boolean remove(Object key)
+	{
+		return remove ((Serializable) key);
+	}
+
 	public boolean remove(Serializable key)
 	{
 		Element element = ehcache.get(key);
 		refList.remove(key);
 		if (element == null)
 			return false;
-		return ehcache.remove(key);
+        boolean isRemoved = ehcache.remove(key);
+        if (isRemoved)
+    		notifyListeners(true, CacheElement.ActionRemoved,key,null);
+        return isRemoved;
 	}
 
 	public boolean removeQuiet(Object key)
@@ -138,19 +155,13 @@
 		}
     }
 	
-    public void addEventListener(JetspeedCacheEventListener listener)
-    {
-        listeners.add(listener);
-    }
-    
-    public void removeEventListener(JetspeedCacheEventListener listener)
-    {
-        listeners.remove(listener);
-    }
-
-	
-	public void notifyElement(Element arg1, int action)
+	public void notifyElement( Ehcache cache, boolean local,Element arg1, int action)
 	{
+		if (cache != this.ehcache)
+		{
+			System.out.println ("Cache=" + cache.getName() + " is not my cache=" + this.ehcache.getName());
+			return;
+		}
 		try
 		{
 			EhCacheDistributedElementImpl e = (EhCacheDistributedElementImpl) refList
@@ -159,7 +170,10 @@
 			{
 				if (action < 0)
 					refList.remove(arg1.getKey());
+				else if (action == CacheElement.ActionAdded)
+					refList.put(arg1.getKey(), arg1);
 				e.notifyChange(action);
+				notifyListeners(local, action,arg1.getKey(),arg1.getObjectValue());
 			}
 		} catch (Exception e)
 		{
@@ -169,74 +183,55 @@
 
 	public void notifyElementEvicted(Ehcache cache, Element arg1)
 	{
-		try
-		{
-			notifyElement(arg1, DistributedCacheElement.ActionEvicted);
-		} catch (Exception e)
-		{
-			e.printStackTrace();
-		}
+			notifyElement(cache, false, arg1,CacheElement.ActionEvicted);
 	}
 
 	public void notifyElementExpired(Ehcache cache, Element arg1)
 	{
-		try
-		{
-			notifyElement(arg1, DistributedCacheElement.ActionExpired);
-		} catch (Exception e)
-		{
-			e.printStackTrace();
-		}
+		notifyElement(cache, false, arg1,CacheElement.ActionExpired);
 	}
 
 	public void notifyElementPut(Ehcache cache, Element arg1)
 			throws CacheException
 	{
-		try
-		{
-			notifyElement(arg1, DistributedCacheElement.ActionAdded);
-		} catch (Exception e)
-		{
-			e.printStackTrace();
-		}
+		
+			notifyElement(cache, false, arg1, CacheElement.ActionAdded);
 	}
 
 	public void notifyElementRemoved(Ehcache cache, Element arg1)
 			throws CacheException
 	{
-		try
-		{
-			EhCacheDistributedElementImpl e = (EhCacheDistributedElementImpl) refList
-					.get(arg1.getKey());
-			if (e != null)
-			{
-				refList.remove(arg1.getKey());
-				e.notifyChange(DistributedCacheElement.ActionRemoved);
-			}
-		} catch (Exception e)
-		{
-			e.printStackTrace();
-		}
+		notifyElement(cache, false, arg1,CacheElement.ActionRemoved);
 	}
 
 	public void notifyElementUpdated(Ehcache cache, Element arg1)
 			throws CacheException
 	{
+		notifyElement(cache, false,arg1,CacheElement.ActionChanged);
+	}
+	public void notifyRemoveAll(Ehcache cache)
+	{
+		if (cache != this.ehcache)
+		{
+			System.out.println ("Cache=" + cache.getName() + " is not my cache=" + this.ehcache.getName());
+			return;
+		}
 		try
 		{
-			notifyElement(arg1, DistributedCacheElement.ActionChanged);
+			Iterator it = refList.entrySet().iterator();
+			while (it.hasNext())
+			{
+				EhCacheDistributedElementImpl e = (EhCacheDistributedElementImpl)it.next();
+				notifyListeners(false, CacheElement.ActionRemoved,e.getKey(),e);
+				e.notifyChange(CacheElement.ActionRemoved);
+			}
+			refList.clear();
 		} catch (Exception e)
 		{
 			e.printStackTrace();
 		}
-	}
-	public void notifyRemoveAll(Ehcache cache)
-	{
-//		if (ehcache == cache)
-//			System.out.println("notifyRemoveAll cache=" + cache.getName());
-//		else
-//			System.out.println("NOT MINE 	notifyRemoveAll cache="
-//					+ cache.getName());
+
+	
 	}
 
 }

Modified: portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java (original)
+++ portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhCacheImpl.java Tue Feb 20 21:55:40 2007
@@ -19,25 +19,22 @@
 import java.util.List;
 
 import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheException;
-import net.sf.ehcache.Ehcache;
 import net.sf.ehcache.Element;
-import net.sf.ehcache.event.CacheEventListener;
 
 import org.apache.jetspeed.cache.CacheElement;
 import org.apache.jetspeed.cache.JetspeedCache;
 import org.apache.jetspeed.cache.JetspeedCacheEventListener;
 
-public class EhCacheImpl implements JetspeedCache, CacheEventListener
+public class EhCacheImpl implements JetspeedCache
 {
     protected Cache ehcache;
-    protected List listeners = new ArrayList();
+    protected List localListeners = new ArrayList();
+    protected List remoteListeners = new ArrayList();
     
     public EhCacheImpl(Cache ehcache)
     {
         this.ehcache = ehcache;
-        ehcache.getCacheEventNotificationService().registerListener(this);
-    }
+     }
 
     public CacheElement get(Object key)
     {
@@ -67,6 +64,7 @@
     {
     	EhCacheElementImpl impl = (EhCacheElementImpl)element;
         ehcache.put(impl.getImplElement());
+		notifyListeners(true, CacheElement.ActionAdded,impl.getKey(),impl.getContent());
     }
     
     public CacheElement createElement(Object key, Object content)
@@ -81,12 +79,24 @@
         Element element = ehcache.get(key);
         if (element == null)
             return false;
-        return ehcache.remove(key);
+        boolean isRemoved = ehcache.remove(key);
+        if (isRemoved)
+    		notifyListeners(true, CacheElement.ActionRemoved,key,null);
+        return isRemoved;
     }
+    
+    public boolean removeQuiet(Object key)
+    {
+        Element element = ehcache.get(key);
+        if (element == null)
+            return false;
+        return ehcache.removeQuiet(key);
+    }   
 
     public void clear()
     {
         ehcache.removeAll();
+		notifyListeners(true, CacheElement.ActionRemoved,null,null);
     }
     
     public void evictContentForUser(String user)
@@ -99,14 +109,22 @@
         return primary;
     }
 
-    public void addEventListener(JetspeedCacheEventListener listener)
+    public void addEventListener(JetspeedCacheEventListener listener, boolean local)
     {
-        listeners.add(listener);
-    }
-    
-    public void removeEventListener(JetspeedCacheEventListener listener)
-    {
-        listeners.remove(listener);
+    	if (local)
+    		localListeners.add(listener);
+    	else
+    		remoteListeners.add(listener);
+    		
+    }
+    
+    public void removeEventListener(JetspeedCacheEventListener listener, boolean local)
+    {
+        if (local)
+        	localListeners.remove(listener);
+        else
+        	remoteListeners.remove(listener);
+        	
     }
    
     // ------------------------------------------------------
@@ -120,33 +138,42 @@
     {
     }
 
-    public void notifyElementEvicted(Ehcache c, Element element)
-    {
-    }
-
-    public void notifyElementExpired(Ehcache c, Element element)
-    {
-    }
-
-    public void notifyElementPut(Ehcache c, Element element) throws CacheException
-    {
-    }
-
-    public void notifyElementRemoved(Ehcache c, Element element) throws CacheException
+    protected void notifyListeners(boolean local, int action, Object key, Object value)
     {
+    	List listeners = (local?localListeners:remoteListeners);
         for (int ix = 0; ix < listeners.size(); ix++)
         {
-            //System.out.println("## element is " + element.getObjectValue().getClass());
-            ((JetspeedCacheEventListener)listeners.get(ix)).notifyElementRemoved(this, element.getObjectValue());
+        	try
+        	{
+        		JetspeedCacheEventListener listener = (JetspeedCacheEventListener)listeners.get(ix);
+        		switch (action)
+        		{
+        			case CacheElement.ActionAdded:
+        				listener.notifyElementAdded(this,local, key,value);
+        				break;
+        			case CacheElement.ActionChanged:
+        				listener.notifyElementChanged(this,local, key,value);
+        				break;
+        			case CacheElement.ActionRemoved:
+        				listener.notifyElementRemoved(this,local, key,value);
+        				break;
+        			case CacheElement.ActionEvicted:
+        				listener.notifyElementEvicted(this,local, key,value);
+        				break;
+        			case CacheElement.ActionExpired:
+        				listener.notifyElementExpired(this,local, key,value);
+        				break;
+        		}
+        	}
+        	catch (Exception e)
+        	{
+        		e.printStackTrace();
+        		
+        	}
         }
-    }
-
-    public void notifyElementUpdated(Ehcache c, Element element) throws CacheException
-    {
-    }
-
-    public void notifyRemoveAll(Ehcache c)
-    {
+    	
+    	
+    	
     }
 
 }

Modified: portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheElementImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheElementImpl.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheElementImpl.java (original)
+++ portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheElementImpl.java Tue Feb 20 21:55:40 2007
@@ -15,9 +15,13 @@
 
 package org.apache.jetspeed.cache.impl;
 
+import java.util.StringTokenizer;
+
 import net.sf.ehcache.Element;
 
 import org.apache.jetspeed.cache.CacheElement;
+import org.apache.jetspeed.cache.JetspeedCache;
+import org.apache.jetspeed.cache.JetspeedCacheEventListener;
 
 /**
  * Wrapper around actual cache element implementation
@@ -30,11 +34,17 @@
     Element element;
     public static final String KEY_SEPARATOR = "/";
     
-    public EhPortletContentCacheElementImpl(Element element)
+    
+ 
+
+	public EhPortletContentCacheElementImpl(Element element)
     {
         this.element = element;
     }
-    
+
+
+
+	
     public Object getKey()
     {
         return element.getObjectKey();

Modified: portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheImpl.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheImpl.java (original)
+++ portals/jetspeed-2/trunk/components/cm/src/java/org/apache/jetspeed/cache/impl/EhPortletContentCacheImpl.java Tue Feb 20 21:55:40 2007
@@ -19,12 +19,14 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.StringTokenizer;
 
 import net.sf.ehcache.Cache;
 import net.sf.ehcache.Element;
 
 import org.apache.jetspeed.cache.CacheElement;
 import org.apache.jetspeed.cache.JetspeedCache;
+import org.apache.jetspeed.cache.JetspeedCacheEventListener;
 
 /**
  * Wrapper around actual cache implementation
@@ -32,9 +34,82 @@
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  * @version $Id: $
  */
-public class EhPortletContentCacheImpl extends EhCacheImpl implements JetspeedCache
+public class EhPortletContentCacheImpl extends EhCacheImpl implements JetspeedCache, JetspeedCacheEventListener
 {
-   
+	
+    public static final String KEY_ENTITY_KEY = EhPortletContentCacheElementImpl.KEY_SEPARATOR + "portlet_entity" + EhPortletContentCacheElementImpl.KEY_SEPARATOR ;
+    public static final int KEY_ENTITY_KEY_LENGTH = KEY_ENTITY_KEY.length();
+
+	   JetspeedCache preferenceCache = null;
+
+	   public void notifyElementAdded(JetspeedCache cache, boolean local, Object key, Object element)
+	{
+		// TODO Auto-generated method stub
+		
+	}
+
+	public void notifyElementChanged(JetspeedCache cache, boolean local, Object key, Object element)
+	{
+		// TODO Auto-generated method stub
+		
+	}
+
+	public void notifyElementEvicted(JetspeedCache cache, boolean local, Object key, Object element)
+	{
+		// TODO Auto-generated method stub
+		
+		notifyElementRemoved(cache,local,key,element);
+	}
+
+	public void notifyElementExpired(JetspeedCache cache, boolean local, Object key, Object element)
+	{
+		// TODO Auto-generated method stub
+		notifyElementRemoved(cache,local,key,element);
+		
+	}
+
+	public void notifyElementRemoved(JetspeedCache cache, boolean local, Object key, Object element)
+		{
+		   if (local)
+			   return; //not interested in local changes
+			   
+		   	//System.out.println("notifying PortletContent that element " + key.toString() + " has been removed");		   
+			if (!(key instanceof String))
+				return;
+			String s = (String) key;
+			if (!(s.startsWith(KEY_ENTITY_KEY)))
+				return;
+			StringTokenizer st = new StringTokenizer(s,EhPortletContentCacheElementImpl.KEY_SEPARATOR);
+			int count = 0;
+			String pe = null; String user = null;
+		     while (st.hasMoreTokens()) 
+		     {
+		    	 String temp = st.nextToken();
+		    	 switch (count)
+		    	 {
+		    		 case 0: 
+		    			 break;
+		    		 case 1: 	pe = temp;
+		    	 		break;
+		    		 case 2: 	user = temp;
+		    		 break;
+		    	 }
+		    	 count++;
+		    	 if (count> 2)
+		    		 break;
+		     }
+			 if ((pe != null) && (user != null))
+				 removeOneEntry(user,pe);
+		}
+	    
+	public EhPortletContentCacheImpl(Cache ehcache,JetspeedCache preferenceCache )
+    {
+        this(ehcache);
+        this.preferenceCache = preferenceCache;
+        preferenceCache.addEventListener(this,false); //only listen to remote events
+    }
+
+	    
     public EhPortletContentCacheImpl(Cache ehcache)
     {
         super(ehcache);
@@ -112,6 +187,24 @@
             }
         }
         return removed;
+    }
+    
+    public void removeOneEntry(String pe, String user)
+    {
+        String key = createCacheKey(pe,user);
+        if (ehcache.remove(key))
+        {
+        	Element userElement = ehcache.get(user);
+	        	
+	        if (userElement != null)
+	        {
+	            Map map = (Map)userElement.getObjectValue();
+	            if (map != null)
+	            {
+	            	map.remove(pe);
+	            }
+	        }
+        }
     }
     
     public void evictContentForUser(String user)

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/window/impl/PortletWindowAccessorImpl.java Tue Feb 20 21:55:40 2007
@@ -27,12 +27,16 @@
 import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
 import org.apache.jetspeed.components.portletentity.PortletEntityNotGeneratedException;
 import org.apache.jetspeed.components.portletentity.PortletEntityNotStoredException;
+import org.apache.jetspeed.components.portletregistry.PortletRegistry;
+import org.apache.jetspeed.components.portletregistry.RegistryEventListener;
 import org.apache.jetspeed.container.window.FailedToCreateWindowException;
 import org.apache.jetspeed.container.window.FailedToRetrievePortletWindow;
 import org.apache.jetspeed.container.window.PortletWindowAccessor;
 import org.apache.jetspeed.factory.PortletFactory;
+import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
 import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
 import org.apache.jetspeed.om.common.portlet.PortletApplication;
+import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
 import org.apache.jetspeed.om.page.ContentFragment;
 import org.apache.jetspeed.om.window.impl.PortletWindowImpl;
 import org.apache.jetspeed.util.ArgUtil;
@@ -46,13 +50,13 @@
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  * @version $Id: PortletWindowAccessorImpl.java,v 1.12 2005/04/29 14:01:57 weaver Exp $
  */
-public class PortletWindowAccessorImpl implements PortletWindowAccessor 
+public class PortletWindowAccessorImpl implements PortletWindowAccessor, RegistryEventListener
 {
     protected final static Log log = LogFactory.getLog(PortletWindowAccessorImpl.class);
    
     private Map windows = Collections.synchronizedMap(new HashMap());    
-        
     private PortletEntityAccessComponent entityAccessor;
+    private PortletRegistry registry = null;
     private PortletFactory portletFactory;
     private boolean validateWindows = false;
     
@@ -64,6 +68,18 @@
         this.validateWindows = validateWindows;
     }
 
+    public PortletWindowAccessorImpl(PortletEntityAccessComponent entityAccessor, 
+                                     PortletFactory portletFactory, 
+                                     PortletRegistry registry,
+                                     boolean validateWindows)
+    {
+        this.entityAccessor = entityAccessor;
+        this.portletFactory = portletFactory;
+        this.registry = registry;
+        this.validateWindows = validateWindows;
+        registry.addRegistryListener(this);
+    }
+    
     public PortletWindow createPortletWindow(PortletEntity entity, String windowId)
     {
         if(entity == null)
@@ -230,7 +246,7 @@
         
         if ( !temporaryWindow )
         {
-            windows.put(fragment.getId(), portletWindow);       
+            windows.put(fragment.getId(), portletWindow);   
         }
         
         return portletWindow;
@@ -243,13 +259,13 @@
         for(int i = 0; i < tmpWindows.size(); i++)
         {
             PortletWindow window = (PortletWindow)((Map.Entry)tmpWindows.get(i)).getValue();
-            
-
-            if(portletEntity.getId().equals(window.getPortletEntity().getId()))
+            if (portletEntity.getId().equals(window.getPortletEntity().getId()))
             {
                 removeWindow(window);
             }
         }        
+        tmpWindows.clear();
+
     }
     
     public void removeWindow(PortletWindow window)
@@ -289,5 +305,81 @@
     public Set getPortletWindows()
     {
         return this.windows.entrySet();
+    }
+
+    protected void removeForPortletDefinition(PortletDefinitionComposite def)
+    {
+        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.getUniqueName().equals(windowDef.getUniqueName()))
+            {
+                removeWindow(window);
+            }
+        }        
+        tmpWindows.clear(); 
+        portletFactory.updatePortletConfig(def);
+    }
+
+    protected void removeForPortletApplication(MutablePortletApplication app)
+    {
+        List tmpWindows = new ArrayList(windows.entrySet());
+        for (int i = 0; i < tmpWindows.size(); i++)
+        {
+            PortletWindow window = (PortletWindow)((Map.Entry)tmpWindows.get(i)).getValue();
+            MutablePortletApplication windowApp = (MutablePortletApplication)window.getPortletEntity().getPortletDefinition().getPortletApplicationDefinition();            
+            if(app.getName().equals(windowApp.getName()))
+            {
+                removeWindow(window);
+            }
+        }        
+        tmpWindows.clear();        
+    }
+    
+    public void applicationRemoved(MutablePortletApplication app)
+    {
+        if (app == null)
+        {
+            //System.out.println("@@@ receiving APP REMOVED message with NULL");
+            return;
+        }
+        //System.out.println("@@@ receiving APP REMOVED message: " + app.getName());
+        removeForPortletApplication(app);
+    }
+
+ 
+    public void applicationUpdated(MutablePortletApplication app)
+    {
+        if (app == null)
+        {
+            //System.out.println("@@@ receiving APP UPDATED message with NULL");
+            return;
+        }
+        //System.out.println("@@@ receiving APP UPDATED message: " + app.getName()); 
+        removeForPortletApplication(app);
+    }
+
+    public void portletRemoved(PortletDefinitionComposite def)
+    {
+        if (def == null)
+        {
+            //System.out.println("@@@ receiving DEF REMOVED message with NULL");
+            return;
+        }
+        //System.out.println("@@@ receiving DEF REMOVED message: " + def.getName()); 
+        removeForPortletDefinition(def);
+    }
+ 
+    public void portletUpdated(PortletDefinitionComposite def)
+    {
+        if (def == null)
+        {
+            //System.out.println("@@@ receiving DEF UPDATED message with NULL");
+            return;
+        }
+        //System.out.println("@@@ receiving DEF UPDATED message: " + def.getName());
+        removeForPortletDefinition(def);
     }
 }

Modified: portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/PortletFactoryMock.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/PortletFactoryMock.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/PortletFactoryMock.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/test/org/apache/jetspeed/PortletFactoryMock.java Tue Feb 20 21:55:40 2007
@@ -39,4 +39,6 @@
     public boolean isPortletApplicationRegistered(PortletApplication pa){return true;}
     
     public static final PortletFactoryMock instance = new PortletFactoryMock();
+    
+    public void updatePortletConfig(PortletDefinition pd) {}
 }

Modified: portals/jetspeed-2/trunk/components/portlet-factory/src/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portlet-factory/src/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/components/portlet-factory/src/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java (original)
+++ portals/jetspeed-2/trunk/components/portlet-factory/src/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java Tue Feb 20 21:55:40 2007
@@ -15,8 +15,10 @@
  */
 package org.apache.jetspeed.factory;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Map;
 
 import javax.portlet.Portlet;
 import javax.portlet.PortletConfig;
@@ -28,6 +30,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.container.JetspeedPortletConfig;
 import org.apache.jetspeed.container.PortalAccessor;
 import org.apache.jetspeed.om.common.portlet.PortletApplication;
 import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
@@ -47,20 +50,20 @@
 public class JetspeedPortletFactory implements PortletFactory
 {
 
-    private HashMap portletCache;
-    private HashMap validatorCache;
+    private Map portletCache;
+    private Map validatorCache;
     
     private static final Log log = LogFactory.getLog(JetspeedPortletFactory.class);
-    private final HashMap classLoaderMap;
+    private final Map classLoaderMap;
 
     /**
      * 
      */
     public JetspeedPortletFactory()
     {
-        this.portletCache = new HashMap();
-        this.validatorCache = new HashMap();
-        classLoaderMap = new HashMap();
+        this.portletCache =  Collections.synchronizedMap(new HashMap());
+        this.validatorCache = Collections.synchronizedMap(new HashMap());
+        classLoaderMap = Collections.synchronizedMap(new HashMap());
     }
 
     public void registerPortletApplication(PortletApplication pa, ClassLoader cl)
@@ -248,6 +251,21 @@
             throw new UnavailableException( "Failed to load portlet " + pd.getClassName() +": "+e.toString());
         }
         return portlet;
+    }
+    
+    public void updatePortletConfig(PortletDefinition pd)
+    {
+        if (pd != null)
+        {
+            //System.out.println("$$$$ updating portlet config for " + pd.getName());
+            String key = pd.getId().toString();
+            PortletInstance instance = (PortletInstance)portletCache.get(key);
+            if (instance != null)
+            {
+                JetspeedPortletConfig config = (JetspeedPortletConfig)instance.getConfig();
+                config.setPortletDefinition(pd);
+            }
+        }
     }
     
     public ClassLoader getPortletApplicationClassLoader(PortletApplication pa)

Modified: portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java (original)
+++ portals/jetspeed-2/trunk/components/prefs/src/java/org/apache/jetspeed/prefs/impl/PersistenceBrokerPreferencesProvider.java Tue Feb 20 21:55:40 2007
@@ -20,9 +20,9 @@
 import java.util.Iterator;
 import java.util.Vector;
 
-import org.apache.jetspeed.cache.DistributedCacheElement;
+import org.apache.jetspeed.cache.CacheElement;
 import org.apache.jetspeed.cache.DistributedCacheObject;
-import org.apache.jetspeed.cache.DistributedJetspeedCache;
+import org.apache.jetspeed.cache.JetspeedCache;
 import org.apache.jetspeed.components.dao.InitablePersistenceBrokerDaoSupport;
 import org.apache.jetspeed.prefs.FailedToCreateNodeException;
 import org.apache.jetspeed.prefs.NodeAlreadyExistsException;
@@ -130,38 +130,38 @@
 
 	    	switch (action)
 	    	{
-	    		case DistributedCacheElement.ActionAdded:
-					//System.out.println("CacheObject Added =" + this.getKey());
+	    		case CacheElement.ActionAdded:
+//					System.out.println("CacheObject Added =" + this.getKey());
 	    			break;
-	    		case DistributedCacheElement.ActionChanged:
-					//System.out.println("CacheObject Changed =" + this.getKey());
+	    		case CacheElement.ActionChanged:
+//					System.out.println("CacheObject Changed =" + this.getKey());
 					if (this.node != null)
 						this.node.invalidate();
 	    			break;
-	    		case DistributedCacheElement.ActionRemoved:
-					//System.out.println("CacheObject Removed =" + this.getKey());
+	    		case CacheElement.ActionRemoved:
+//					System.out.println("CacheObject Removed =" + this.getKey());
 					if (this.node != null)
 						this.node.invalidate();
 	    			break;
-	    		case DistributedCacheElement.ActionEvicted:
-					//System.out.println("CacheObject Evicted =" + this.getKey());
+	    		case CacheElement.ActionEvicted:
+//					System.out.println("CacheObject Evicted =" + this.getKey());
 					if (this.node != null)
 						this.node.invalidate();
 	    			break;
-	    		case DistributedCacheElement.ActionExpired:
-					//System.out.println("CacheObject Expired =" + this.getKey());
+	    		case CacheElement.ActionExpired:
+//					System.out.println("CacheObject Expired =" + this.getKey());
 					if (this.node != null)
 						this.node.invalidate();
 	    			break;
 	    		default:
-					//System.out.println("CacheObject - UNKOWN OPRERATION =" + this.getKey());
+					System.out.println("CacheObject - UNKOWN OPRERATION =" + this.getKey());
 	    			return;
 	    	}
 	    	return;
 		}
     }
 
-    private DistributedJetspeedCache preferenceCache;
+    private JetspeedCache preferenceCache;
     
     
     /**
@@ -193,7 +193,7 @@
      *             if the <code>prefsFactoryImpl</code> argument does not reperesent a Class that exists in the
      *             current classPath.
      */
-    public PersistenceBrokerPreferencesProvider(String repositoryPath, DistributedJetspeedCache preferenceCache)
+    public PersistenceBrokerPreferencesProvider(String repositoryPath, JetspeedCache preferenceCache)
             throws ClassNotFoundException
     {
         this(repositoryPath);
@@ -202,7 +202,7 @@
 
     protected void addToCache(NodeCache content)
     {
-        DistributedCacheElement cachedElement = preferenceCache.createElement(content.getCacheKey(), content);
+        CacheElement cachedElement = preferenceCache.createElement(content.getCacheKey(), content);
         cachedElement.setTimeToIdleSeconds(preferenceCache.getTimeToIdleSeconds());
         cachedElement.setTimeToLiveSeconds(preferenceCache.getTimeToLiveSeconds());
         preferenceCache.put(cachedElement);        
@@ -210,7 +210,7 @@
   
     private NodeCache getNode(String cacheKey)
     {
-        DistributedCacheElement cachedElement = preferenceCache.get(cacheKey);
+    	CacheElement cachedElement = preferenceCache.get(cacheKey);
         if (cachedElement != null)
          return (NodeCache)cachedElement.getContent();  
         return null;

Modified: portals/jetspeed-2/trunk/components/registry/etc/assembly/registry-test.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/registry/etc/assembly/registry-test.xml?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/components/registry/etc/assembly/registry-test.xml (original)
+++ portals/jetspeed-2/trunk/components/registry/etc/assembly/registry-test.xml Tue Feb 20 21:55:40 2007
@@ -35,6 +35,12 @@
         <constructor-arg index="3">
             <ref bean="portletDefinitionOidCache" />
         </constructor-arg>
+        <constructor-arg index="4">
+            <ref bean="portletApplicationNameCache" />
+        </constructor-arg>
+        <constructor-arg index="5">
+            <ref bean="portletDefinitionNameCache" />
+        </constructor-arg>        
     </bean>
 
     <bean id="org.apache.jetspeed.components.portletregistry.PortletRegistry" name="portletRegistry" parent="baseTransactionProxy">
@@ -56,45 +62,6 @@
         </property>
     </bean>
 
-    <!-- Portlet Entity Access DAO-->
-    <!--
-        <bean id="systemCache" class="org.apache.jetspeed.cache.general.SimpleHashMapCache" />
-        
-        <bean id="systemCachingInterceptor" class="org.apache.jetspeed.components.interceptors.CachingInterceptor" >
-        <constructor-arg>
-        <ref bean="systemCache"/>
-        </constructor-arg>
-        </bean>
-        
-        <bean id="systemRemoveFromCacheInterceptor" class="org.apache.jetspeed.components.interceptors.RemoveFromCacheInterceptor" >
-        <constructor-arg>
-        <ref bean="systemCache"/>
-        </constructor-arg>
-        </bean>   	
-        
-        <bean id="portletEntityCachingAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
-        <property name="advice">
-        <ref bean="systemCachingInterceptor"/>
-        </property>
-        <property name="patterns">
-        <list>
-        <value>.*getPortletEntity.*</value>
-        </list>
-        </property>
-        </bean>
-        
-        <bean id="portletEntityRemoveFromCacheAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
-        <property name="advice">
-        <ref bean="systemRemoveFromCacheInterceptor"/>
-        </property>
-        <property name="patterns">
-        <list>
-        <value>.*removePortletEntity.*</value>
-        </list>
-        </property>
-        </bean>
-        
-    -->
     <!--
         - PortletEntity business object: OJB implementation, as an inner bean wrapped
         - by an outer transactional proxy. The two bean definitions could have been separate,

Modified: portals/jetspeed-2/trunk/components/registry/src/java/JETSPEED-INF/ojb/registry_repository.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/registry/src/java/JETSPEED-INF/ojb/registry_repository.xml?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/components/registry/src/java/JETSPEED-INF/ojb/registry_repository.xml (original)
+++ portals/jetspeed-2/trunk/components/registry/src/java/JETSPEED-INF/ojb/registry_repository.xml Tue Feb 20 21:55:40 2007
@@ -396,7 +396,7 @@
         name="app"
         class-ref="org.apache.jetspeed.om.portlet.impl.PortletApplicationDefinitionImpl"
         auto-delete="false"
-        auto-update = "true"
+        auto-update = "false"
         auto-retrieve = "true"
      >
          <foreignkey field-ref="appId"/>

Modified: portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java (original)
+++ portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java Tue Feb 20 21:55:40 2007
@@ -22,6 +22,7 @@
 import java.util.prefs.BackingStoreException;
 
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
+import org.apache.jetspeed.container.window.PortletWindowAccessor;
 import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
 import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
 import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
@@ -38,6 +39,7 @@
 import org.apache.pluto.om.entity.PortletEntity;
 import org.apache.pluto.om.entity.PortletEntityCtrl;
 import org.apache.pluto.om.portlet.PortletDefinition;
+import org.apache.pluto.om.window.PortletWindow;
 import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport;
 
 /**
@@ -58,6 +60,7 @@
 {
     private PortletRegistry registry;
     private RequestContextComponent rcc;
+    private PortletWindowAccessor windowAccessor = null;
     
     // 2006-08-22: by default, do not merge preferences from the shared preferences area 
     // up until this point, all preferences were shared. With JS2-449, preferences are now
@@ -318,10 +321,17 @@
     }
     
     
-    public void removeFromCache( PortletEntity entity )
+    public void removeFromCache(PortletEntity entity)
     {
-        // TODO Auto-generated method stub
-
+        if (windowAccessor != null)
+        {
+            String windowId = entity.getId().toString();
+            PortletWindow window = windowAccessor.getPortletWindow(windowId);
+            if (window != null)
+            {
+                windowAccessor.removeWindow(window);
+            }
+        }
     }
 
     public void removePortletEntities( PortletDefinition portletDefinition ) throws PortletEntityNotDeletedException
@@ -345,6 +355,7 @@
             try
             {
                 ((PrefsPreferenceSetImpl)prefsSet).clear();
+                removeFromCache(portletEntity);
             }
             catch (BackingStoreException e)
             {

Modified: portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java (original)
+++ portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java Tue Feb 20 21:55:40 2007
@@ -15,9 +15,11 @@
  */
 package org.apache.jetspeed.components.portletregistry;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.prefs.BackingStoreException;
@@ -66,32 +68,38 @@
 
     private JetspeedCache applicationOidCache = null;
     private JetspeedCache portletOidCache = null;
+    private JetspeedCache applicationNameCache = null;
+    private JetspeedCache portletNameCache = null;
     private Map nameCache = new HashMap(); // work in progress (switch to JetspeedCache)
+    private List listeners = new ArrayList();
     
     // for testing purposes only: no need for the portletFactory then
     public PersistenceBrokerPortletRegistry(String repositoryPath)
     {
-        this(repositoryPath, null, null, null);
+        this(repositoryPath, null, null, null, null, null);
     }
     
     /**
      *  
      */
     public PersistenceBrokerPortletRegistry(String repositoryPath, PortletFactory portletFactory, 
-            JetspeedCache applicationOidCache, JetspeedCache portletOidCache)
+            JetspeedCache applicationOidCache, JetspeedCache portletOidCache, 
+            JetspeedCache applicationNameCache, JetspeedCache portletNameCache)
     {
         super(repositoryPath);
         PortletDefinitionImpl.setPortletRegistry(this);
         PortletDefinitionImpl.setPortletFactory(portletFactory);
         this.applicationOidCache = applicationOidCache;
         this.portletOidCache = portletOidCache;
+        this.applicationNameCache = applicationNameCache;
+        this.portletNameCache = portletNameCache;
         MutablePortletApplicationProxy.setRegistry(this);
-        RegistryApplicationCache.cacheInit(this, applicationOidCache);
-        RegistryPortletCache.cacheInit(this, applicationOidCache);
-        this.applicationOidCache.addEventListener(this);
-        this.portletOidCache.addEventListener(this);
+        RegistryApplicationCache.cacheInit(this, applicationOidCache, applicationNameCache, listeners);
+        RegistryPortletCache.cacheInit(this, portletOidCache, portletNameCache, listeners);
+        this.applicationNameCache.addEventListener(this, false);
+        this.portletNameCache.addEventListener(this, false);        
     }
-
+    
     public Language createLanguage( Locale locale, String title, String shortTitle, String description,
             Collection keywords ) throws RegistryException
     {
@@ -326,26 +334,66 @@
         return portlet;
     }
     
-    public void notifyElementRemoved(JetspeedCache cache, Object o)
+    public void notifyElementAdded(JetspeedCache cache, boolean local, Object key, Object element)
     {
-        //System.out.println("--- Registry: notification element is a " + o);
-        // update nameCache
     }
-    
-    protected MutablePortletApplication getProxiedObject(MutablePortletApplication app)
+
+    public void notifyElementChanged(JetspeedCache cache, boolean local, Object key, Object element)
+    {
+    }
+
+    public void notifyElementEvicted(JetspeedCache cache, boolean local, Object key, Object element)
+    {
+        //notifyElementRemoved(cache,local,key,element);
+    }
+
+    public void notifyElementExpired(JetspeedCache cache, boolean local, Object key, Object element)
     {
-        PortletApplicationProxy cached = (PortletApplicationProxy)nameCache.get(app.getName());
-        if (cached != null)
+        //notifyElementRemoved(cache,local,key,element);           
+    }
+
+    public void notifyElementRemoved(JetspeedCache cache, boolean local, Object key, Object element)
+    {    
+       
+        if (cache == this.portletNameCache)
         {
-            cached.setRealApplication(app);
-            return (MutablePortletApplication)cached;            
+            //System.out.println("%%% portlet remote removed " + key);            
+            RegistryPortletCache.cacheRemoveQuiet((String)key, (RegistryCacheObjectWrapper)element);
+            PortletDefinitionComposite pd = this.getPortletDefinitionByUniqueName((String)key);
+            if (listeners != null)
+            {
+                for (int ix=0; ix < listeners.size(); ix++)
+                {
+                    RegistryEventListener listener = (RegistryEventListener)listeners.get(ix);
+                    listener.portletRemoved(pd);
+                }        
+            }           
         }
         else
         {
-            MutablePortletApplication proxy = MutablePortletApplicationProxy.createProxy(app);
-            nameCache.put(app.getName(), proxy);
-            return (MutablePortletApplication)cached;
+            //System.out.println("%%% PA remote removed " + key);
+            RegistryApplicationCache.cacheRemoveQuiet((String) key, (RegistryCacheObjectWrapper)element);
+            MutablePortletApplication pa = this.getPortletApplication((String)key);
+            if (listeners != null)
+            {
+                for (int ix=0; ix < listeners.size(); ix++)
+                {
+                    RegistryEventListener listener = (RegistryEventListener)listeners.get(ix);
+                    listener.applicationRemoved(pa);
+                }        
+            }
+            
         }
+    }
+        
+    public void addRegistryListener(RegistryEventListener listener)
+    {
+        this.listeners.add(listener);
+    }
+
+    public void removeRegistryEventListner(RegistryEventListener listener)
+    {
+        this.listeners.remove(listener);
     }
     
 }

Modified: portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/RegistryApplicationCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/RegistryApplicationCache.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/RegistryApplicationCache.java (original)
+++ portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/RegistryApplicationCache.java Tue Feb 20 21:55:40 2007
@@ -15,11 +15,16 @@
  */
 package org.apache.jetspeed.components.portletregistry;
 
+import java.util.List;
 import java.util.Properties;
 
 import org.apache.jetspeed.cache.CacheElement;
+import org.apache.jetspeed.cache.DistributedCacheObject;
 import org.apache.jetspeed.cache.JetspeedCache;
+import org.apache.jetspeed.cache.impl.EhCacheDistributedElementImpl;
 import org.apache.jetspeed.cache.impl.EhCacheElementImpl;
+import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
+import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
 import org.apache.ojb.broker.Identity;
 import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.cache.ObjectCache;
@@ -33,16 +38,20 @@
 public class RegistryApplicationCache implements ObjectCache
 {
     private static JetspeedCache oidCache;
+    private static JetspeedCache nameCache;    
     private static PortletRegistry registry;
+    private static List listeners = null;
 
     public RegistryApplicationCache(PersistenceBroker broker, Properties props)
     {
     }
-   
-    public synchronized static void cacheInit(PortletRegistry r, JetspeedCache o)
+       
+    public synchronized static void cacheInit(PortletRegistry r, JetspeedCache o, JetspeedCache n, List l)
     {
         registry = r;
         oidCache = o;
+        nameCache = n;
+        listeners = l;
     }
 
     public Object lookup(Identity oid)
@@ -67,19 +76,24 @@
         cacheAdd(oid, obj);
     }
     public synchronized static void cacheAdd(Identity oid, Object obj)
-    {
-        CacheElement entry = (CacheElement)oidCache.get(oid);
-        if (entry != null)
-        {
-            oidCache.remove(oid);
-            entry = new EhCacheElementImpl(oid, obj);
-            oidCache.put(entry);
-        }
-        else
-        {
-            //MutablePortletApplication proxy = MutablePortletApplicationProxy.createProxy((MutablePortletApplication)obj);
-            entry = new EhCacheElementImpl(oid, obj);
-            oidCache.put(entry);
+    {        
+        oidCache.remove(oid);
+        CacheElement entry = new EhCacheElementImpl(oid, obj);
+        oidCache.put(entry);
+        
+        MutablePortletApplication pa = (MutablePortletApplication)obj;
+        DistributedCacheObject wrapper = new RegistryCacheObjectWrapper(oid, pa.getName());
+        nameCache.remove(pa.getName());
+        CacheElement nameEntry = nameCache.createElement(pa.getName(), wrapper);
+        nameCache.put(nameEntry);
+               
+        if (listeners != null)
+        {        
+            for (int ix=0; ix < listeners.size(); ix++)
+            {
+                RegistryEventListener listener = (RegistryEventListener)listeners.get(ix);
+                listener.applicationUpdated((MutablePortletApplication)obj);
+            }
         }
     }
     
@@ -93,6 +107,7 @@
     public synchronized static void cacheClear()
     {
         oidCache.clear();
+        nameCache.clear();
     }
 
 
@@ -112,7 +127,41 @@
      */
     public synchronized static void cacheRemove(Identity oid)
     {
+        MutablePortletApplication pd = (MutablePortletApplication)cacheLookup(oid);
+        if (pd == null)
+            return;
+        
         oidCache.remove(oid);
+        nameCache.remove(pd.getName());
+        
+        if (listeners != null)
+        {
+            for (int ix=0; ix < listeners.size(); ix++)
+            {
+                RegistryEventListener listener = (RegistryEventListener)listeners.get(ix);
+                listener.applicationRemoved(pd);
+            }        
+        }
+
     }
-    
+
+    public synchronized static void cacheRemoveQuiet(String key, RegistryCacheObjectWrapper w)
+    {
+        RegistryCacheObjectWrapper wrapper = w;
+        if (wrapper == null)
+        {
+            wrapper = (RegistryCacheObjectWrapper)nameCache.get(key);
+            if (wrapper == null)
+                return;
+        }
+        Identity oid = wrapper.getId();      
+        
+        MutablePortletApplication pd = (MutablePortletApplication)cacheLookup(oid);
+        if (pd == null)
+            return;
+        
+        oidCache.removeQuiet(oid);
+        nameCache.removeQuiet(pd.getName());        
+    }
+   
 }

Added: portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/RegistryCacheObjectWrapper.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/RegistryCacheObjectWrapper.java?view=auto&rev=509904
==============================================================================
--- portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/RegistryCacheObjectWrapper.java (added)
+++ portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/RegistryCacheObjectWrapper.java Tue Feb 20 21:55:40 2007
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.components.portletregistry;
+
+import org.apache.jetspeed.cache.CacheElement;
+import org.apache.jetspeed.cache.DistributedCacheObject;
+import org.apache.ojb.broker.Identity;
+
+/**
+ * OJB cache 
+ * 
+ * @author dtaylor
+ *
+ */
+public class RegistryCacheObjectWrapper implements DistributedCacheObject
+{
+    /** The serial uid. */
+    private static final long serialVersionUID = 1853381807991868844L;
+    Identity id = null;
+    String key = null;;
+
+
+    public RegistryCacheObjectWrapper(Identity id, String key)
+    {
+        //System.out.println(this.getClass().getName() + "-" + "NodeCache - fullpath=" + fullpath);
+        this.key = key;
+        this.id = id;
+    }
+
+
+    public Identity getId()
+    {
+        //System.out.println(this.getClass().getName() + "-" +"getNode=" + node.getFullPath());
+        return id;
+    }
+
+    public void setIdentity(Identity id)
+    {
+        // System.out.println(this.getClass().getName() + "-" +"setFullpath=" + node.getFullPath());
+        this.id = id;
+    }
+
+
+    public boolean equals(Object obj)
+    {
+        if (obj != null && obj instanceof RegistryCacheObjectWrapper)
+        {
+            RegistryCacheObjectWrapper other = (RegistryCacheObjectWrapper) obj;
+            return getKey().equals(other.getKey());
+        }
+        return false;
+    }
+
+    public int hashCode()
+    {
+        return getKey().hashCode();
+    }
+
+    public String getCacheKey()
+    {
+        return getKey();
+    }
+
+    public String getKey()
+    {
+        return key;
+    }
+
+    
+    public void notifyChange(int action)
+    {
+
+        switch (action)
+        {
+            case CacheElement.ActionAdded:
+//              System.out.println("CacheObjectAdded =" + this.getKey());
+                break;
+            case CacheElement.ActionChanged:
+//              System.out.println("CacheObjectChanged =" + this.getKey());
+                break;
+            case CacheElement.ActionRemoved:
+//              System.out.println("CacheObjectRemoved =" + this.getKey());
+                break;
+            case CacheElement.ActionEvicted:
+//              System.out.println("CacheObjectEvicted =" + this.getKey());
+                break;
+            case CacheElement.ActionExpired:
+//              System.out.println("CacheObjectExpired =" + this.getKey());
+                break;
+            default:
+                System.out.println("CacheObject -UNKOWN OPRERATION =" + this.getKey());
+                return;
+        }
+        return;
+    }
+}

Modified: portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/RegistryPortletCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/RegistryPortletCache.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/RegistryPortletCache.java (original)
+++ portals/jetspeed-2/trunk/components/registry/src/java/org/apache/jetspeed/components/portletregistry/RegistryPortletCache.java Tue Feb 20 21:55:40 2007
@@ -15,10 +15,13 @@
  */
 package org.apache.jetspeed.components.portletregistry;
 
+import java.util.List;
 import java.util.Properties;
 
 import org.apache.jetspeed.cache.CacheElement;
+import org.apache.jetspeed.cache.DistributedCacheObject;
 import org.apache.jetspeed.cache.JetspeedCache;
+import org.apache.jetspeed.cache.impl.EhCacheDistributedElementImpl;
 import org.apache.jetspeed.cache.impl.EhCacheElementImpl;
 import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
 import org.apache.ojb.broker.Identity;
@@ -34,16 +37,20 @@
 public class RegistryPortletCache implements ObjectCache
 {
     private static JetspeedCache oidCache;
+    private static JetspeedCache nameCache;
     private static PortletRegistry registry;
-
+    private static List listeners = null;
+    
     public RegistryPortletCache(PersistenceBroker broker, Properties props)
     {
     }
     
-    public synchronized static void cacheInit(PortletRegistry r, JetspeedCache o)
+    public synchronized static void cacheInit(PortletRegistry r, JetspeedCache o, JetspeedCache n, List l)
     {
         registry = r;
         oidCache = o;
+        nameCache = n;
+        listeners = l;
     }
 
     public Object lookup(Identity oid)
@@ -69,18 +76,23 @@
     }
     public synchronized static void cacheAdd(Identity oid, Object obj)
     {
-        CacheElement entry = (CacheElement)oidCache.get(oid);
-        if (entry != null)
-        {
-            oidCache.remove(oid);
-            entry = new EhCacheElementImpl(oid, obj);
-            oidCache.put(entry);
-        }
-        else
-        {
-            //PortletDefinitionComposite proxy = PortletDefinitionCompositeProxy.createProxy((PortletDefinitionComposite)obj);            
-            entry = new EhCacheElementImpl(oid, entry);
-            oidCache.put(entry);
+        oidCache.remove(oid);
+        CacheElement entry = new EhCacheElementImpl(oid, obj);
+        oidCache.put(entry);
+        
+        PortletDefinitionComposite pd = (PortletDefinitionComposite)obj;
+        DistributedCacheObject wrapper = new RegistryCacheObjectWrapper(oid, pd.getUniqueName());
+        nameCache.remove(pd.getUniqueName());
+        CacheElement nameEntry = nameCache.createElement(pd.getUniqueName(), wrapper);
+        nameCache.put(nameEntry);
+               
+        if (listeners != null)
+        {        
+            for (int ix=0; ix < listeners.size(); ix++)
+            {
+                RegistryEventListener listener = (RegistryEventListener)listeners.get(ix);
+                listener.portletUpdated((PortletDefinitionComposite)obj);
+            }
         }
     }
     
@@ -94,6 +106,7 @@
     public synchronized static void cacheClear()
     {
         oidCache.clear();
+        nameCache.clear();
     }
 
 
@@ -113,7 +126,40 @@
      */
     public synchronized static void cacheRemove(Identity oid)
     {
+        PortletDefinitionComposite pd = (PortletDefinitionComposite)cacheLookup(oid);
+        if (pd == null)
+            return;
+        
         oidCache.remove(oid);
+        nameCache.remove(pd.getUniqueName());
+        
+        if (listeners != null)
+        {
+            for (int ix=0; ix < listeners.size(); ix++)
+            {
+                RegistryEventListener listener = (RegistryEventListener)listeners.get(ix);
+                listener.portletRemoved(pd);
+            }        
+        }
+    }
+
+    public synchronized static void cacheRemoveQuiet(String key, RegistryCacheObjectWrapper w)
+    {
+        RegistryCacheObjectWrapper wrapper = w;
+        if (wrapper == null)
+        {
+            wrapper = (RegistryCacheObjectWrapper)nameCache.get(key);
+            if (wrapper == null)
+                return;
+        }
+        Identity oid = wrapper.getId();
+
+        PortletDefinitionComposite pd = (PortletDefinitionComposite)cacheLookup(oid);
+        if (pd == null)
+            return;
+     
+        oidCache.removeQuiet(oid);       
+        nameCache.removeQuiet(pd.getUniqueName());        
     }
     
 }

Modified: portals/jetspeed-2/trunk/etc/db-ojb/ehcache.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/etc/db-ojb/ehcache.xml?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/etc/db-ojb/ehcache.xml (original)
+++ portals/jetspeed-2/trunk/etc/db-ojb/ehcache.xml Tue Feb 20 21:55:40 2007
@@ -337,11 +337,13 @@
            timeToIdleSeconds="28800"
            timeToLiveSeconds="28800"
            memoryStoreEvictionPolicy="LFU">
+<!-- 
         <cacheEventListenerFactory
                 class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
-                properties="replicateAsynchronously=false, replicatePuts=false,
-                            replicateUpdates=true, replicateUpdatesViaCopy=false,
+                properties="replicateAsynchronously=true, replicatePuts=false,
+                            replicateUpdates=false, replicateUpdatesViaCopy=false,
                             replicateRemovals=true"/>
+  -->
    </cache>
 
 
@@ -352,28 +354,35 @@
            overflowToDisk="false"
            timeToIdleSeconds="28800"
            timeToLiveSeconds="28800"
-           memoryStoreEvictionPolicy="LFU"
-            />
+           memoryStoreEvictionPolicy="LFU">
+   </cache>
 
-   <cache name="portletDefinitionOidCache"
-           maxElementsInMemory="2000"
+   <cache name="portletApplicationNameCache"
+           maxElementsInMemory="500"
            maxElementsOnDisk="1000"
            eternal="false"
            overflowToDisk="false"
            timeToIdleSeconds="28800"
            timeToLiveSeconds="28800"
-           memoryStoreEvictionPolicy="LFU"
-            />
-            
-   <cache name="portletApplicationNameCache"
-           maxElementsInMemory="500"
+           memoryStoreEvictionPolicy="LFU">
+<!-- 
+        <cacheEventListenerFactory
+                class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
+                properties="replicateAsynchronously=true, replicatePuts=false,
+                            replicateUpdates=false, replicateUpdatesViaCopy=false,
+                            replicateRemovals=true"/>
+ -->                            
+   </cache>
+
+   <cache name="portletDefinitionOidCache"
+           maxElementsInMemory="2000"
            maxElementsOnDisk="1000"
            eternal="false"
            overflowToDisk="false"
            timeToIdleSeconds="28800"
            timeToLiveSeconds="28800"
-           memoryStoreEvictionPolicy="LFU"
-            />
+           memoryStoreEvictionPolicy="LFU">
+            </cache>
 
    <cache name="portletDefinitionNameCache"
            maxElementsInMemory="2000"
@@ -382,9 +391,16 @@
            overflowToDisk="false"
            timeToIdleSeconds="28800"
            timeToLiveSeconds="28800"
-           memoryStoreEvictionPolicy="LFU"
-            />
-
+           memoryStoreEvictionPolicy="LFU">
+ <!-- 
+        <cacheEventListenerFactory
+                class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
+                properties="replicateAsynchronously=true, replicatePuts=false,
+                            replicateUpdates=false, replicateUpdatesViaCopy=false,
+                            replicateRemovals=true"/>
+  -->                           
+            </cache>
+            
     <!--
     Sample distributed cache named sampleDistributedCache1.
     This cache replicates using defaults.

Modified: portals/jetspeed-2/trunk/etc/registration/assembly/registry.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/etc/registration/assembly/registry.xml?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/etc/registration/assembly/registry.xml (original)
+++ portals/jetspeed-2/trunk/etc/registration/assembly/registry.xml Tue Feb 20 21:55:40 2007
@@ -35,6 +35,12 @@
         <constructor-arg index="3">
             <ref bean="portletDefinitionOidCache" />
         </constructor-arg>
+        <constructor-arg index="4">
+            <ref bean="portletApplicationNameCache" />
+        </constructor-arg>
+        <constructor-arg index="5">
+            <ref bean="portletDefinitionNameCache" />
+        </constructor-arg>        
     </bean>
 
     <bean id="org.apache.jetspeed.components.portletregistry.PortletRegistry" name="portletRegistry" parent="baseTransactionProxy">

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/CacheElement.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/CacheElement.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/CacheElement.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/CacheElement.java Tue Feb 20 21:55:40 2007
@@ -28,6 +28,13 @@
  */
 public interface CacheElement
 {
+	public static int ActionAdded  = 1;
+	public static int ActionChanged = 2;
+	public static int ActionRemoved = -1;
+	public static int ActionEvicted = -2;
+	public static int ActionExpired = -3;
+	
+     
     /**
      * 
      * @return the idle time in seconds for this cache element

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/JetspeedCache.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/JetspeedCache.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/JetspeedCache.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/JetspeedCache.java Tue Feb 20 21:55:40 2007
@@ -65,6 +65,14 @@
     boolean remove(Object key);
     
     /**
+     * Remove object from cache, do not notify listeners
+     * 
+     * @param key
+     * @return trie if the object was removed, false otherwise
+     */
+    boolean removeQuiet(Object key);
+    
+    /**
      * 
      * @return the default idle time in seconds for this cache
      */
@@ -93,11 +101,12 @@
     String createCacheKey(String primary, String secondary);
     
     /**
-     * Add a cache listener for supported cache events
+     * Add a cache listener for supported cache events, either for local or remote cache events
      * 
      * @param listener
+     * @param local if true, listen to local events, if false, listen to remote 
      */         
-    void addEventListener(JetspeedCacheEventListener listener);
+    void addEventListener(JetspeedCacheEventListener listener, boolean local);
     
-    void removeEventListener(JetspeedCacheEventListener listener);
+    void removeEventListener(JetspeedCacheEventListener listener, boolean local);
 }

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/JetspeedCacheEventListener.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/JetspeedCacheEventListener.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/JetspeedCacheEventListener.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/cache/JetspeedCacheEventListener.java Tue Feb 20 21:55:40 2007
@@ -17,7 +17,7 @@
 
 /**
  * <p>
- *  Provides interface to Jetspeed for cache events
+ * Provides interface to Jetspeed for cache events
  * </p>
  * 
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
@@ -25,5 +25,85 @@
  */
 public interface JetspeedCacheEventListener
 {
-    void notifyElementRemoved(JetspeedCache cache, Object o);
+
+	/**
+	 * REMOVE notification for cache listeners
+	 * 
+	 * @param cache
+	 *            the Cache repoorting the change
+	 * @param local
+	 *            true if action was local, false if initiated by remote cache
+	 * @param key
+	 *            key of object
+	 * @param element
+	 *            content of object
+	 * 
+	 */
+	void notifyElementRemoved(JetspeedCache cache, boolean local, Object key,
+			Object element);
+
+	/**
+	 * ADDED notification for cache listeners
+	 * 
+	 * @param cache
+	 *            the Cache repoorting the change
+	 * @param local
+	 *            true if action was local, false if initiated by remote cache
+	 * @param key
+	 *            key of object
+	 * @param element
+	 *            content of object
+	 * 
+	 */
+	void notifyElementAdded(JetspeedCache cache, boolean local, Object key,
+			Object element);
+
+	/**
+	 * CHANGE notification for cache listeners
+	 * 
+	 * @param cache
+	 *            the Cache repoorting the change
+	 * @param local
+	 *            true if action was local, false if initiated by remote cache
+	 * @param key
+	 *            key of object
+	 * @param element
+	 *            content of object
+	 * 
+	 */
+	void notifyElementChanged(JetspeedCache cache, boolean local, Object key,
+			Object element);
+
+	/**
+	 * EVICTED notification for cache listeners
+	 * 
+	 * @param cache
+	 *            the Cache repoorting the change
+	 * @param local
+	 *            true if action was local, false if initiated by remote cache
+	 * @param key
+	 *            key of object
+	 * @param element
+	 *            content of object
+	 * 
+	 */
+	void notifyElementEvicted(JetspeedCache cache, boolean local, Object key,
+			Object element);
+
+	/**
+	 * EXPIRED notification for cache listeners
+	 * 
+	 * @param cache
+	 *            the Cache repoorting the change
+	 * @param local
+	 *            true if action was local, false if initiated by remote cache
+	 * @param key
+	 *            key of object
+	 * @param element
+	 *            content of object
+	 * 
+	 */
+	void notifyElementExpired(JetspeedCache cache, boolean local, Object key,
+			Object element);
+
 }

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java Tue Feb 20 21:55:40 2007
@@ -189,6 +189,9 @@
      */
     void savePortletDefinition(PortletDefinition portlet) throws FailedToStorePortletDefinitionException;
 	
+    void addRegistryListener(RegistryEventListener listener);
+    
+    void removeRegistryEventListner(RegistryEventListener listener);
 	
 
 }

Added: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/portletregistry/RegistryEventListener.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/portletregistry/RegistryEventListener.java?view=auto&rev=509904
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/portletregistry/RegistryEventListener.java (added)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/components/portletregistry/RegistryEventListener.java Tue Feb 20 21:55:40 2007
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.components.portletregistry;
+
+import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
+import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
+
+/**
+ * This interface describes the page manager event listener
+ * that is notified when a managed node is updated or removed
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public interface RegistryEventListener
+{
+    /**
+     * applicationUpdated - invoked when the definition of a portlet application is
+     *           updated by the registry or when the
+     *           state modification is otherwise detected
+     *
+     * @param MutablePortletApplicaiton new managed application 
+     */
+    void applicationUpdated(MutablePortletApplication app);
+
+    /**
+     * portletUpdated - invoked when the definition of a portlet definition is
+     *           updated by the registry or when the
+     *           state modification is otherwise detected
+     *
+     * @param PortletDefinitionComposite new managed portlet definition 
+     */
+    void portletUpdated(PortletDefinitionComposite def);
+
+    /**
+     * applicationRemoved - invoked when the definition of a portlet application is
+     *           removed by the registry
+     *           
+     * @param MutablePortletApplicaiton removed portlet application 
+     */
+    void applicationRemoved(MutablePortletApplication app);
+
+    /**
+     * portletUpdated - invoked when the definition of a portlet definition is
+     *           removed by the registry 
+     *
+     * @param PortletDefinitionComposite new managed portlet definition if known
+     */
+    void portletRemoved(PortletDefinitionComposite def);
+    
+}

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/factory/PortletFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/factory/PortletFactory.java?view=diff&rev=509904&r1=509903&r2=509904
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/factory/PortletFactory.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/factory/PortletFactory.java Tue Feb 20 21:55:40 2007
@@ -42,4 +42,5 @@
     ClassLoader getPortletApplicationClassLoader(PortletApplication pa);
     PortletInstance getPortletInstance( ServletContext servletContext, PortletDefinition pd ) throws PortletException;
     PreferencesValidator getPreferencesValidator(PortletDefinition pd );
+    void updatePortletConfig(PortletDefinition pd);
 }



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