[richfaces-svn-commits] JBoss Rich Faces SVN: r5723 - branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Jan 29 17:50:37 EST 2008


Author: alexsmirnov
Date: 2008-01-29 17:50:36 -0500 (Tue, 29 Jan 2008)
New Revision: 5723

Added:
   branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/LRUMap.java
Modified:
   branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/PortletStateHolder.java
Log:
fix 3.1 branch compilation problem

Added: branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/LRUMap.java
===================================================================
--- branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/LRUMap.java	                        (rev 0)
+++ branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/LRUMap.java	2008-01-29 22:50:36 UTC (rev 5723)
@@ -0,0 +1,52 @@
+/**
+ * 
+ */
+package org.ajax4jsf.portlet.application;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map.Entry;
+
+/**
+ * Last Recent Used Map cache. See {@link LinkedHashMap} for details.
+ * @author asmirnov
+ *
+ */
+public class LRUMap<K,V> extends LinkedHashMap<K,V> implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -7232885382582796665L;
+	private int capacity;
+	
+	
+	/**
+	 * @param capacity - maximal cache capacity.
+	 */
+	public LRUMap(int capacity) {
+		super(capacity, 1.0f,true);
+		this.capacity = capacity;
+	}
+
+	
+	protected boolean removeEldestEntry(Entry<K,V> entry) {
+		// Remove last entry if size exceeded.
+		return size()>capacity;
+	}
+
+	/**
+	 * Get most recent used element 
+	 * @return the most Recent value
+	 */
+	public Object getMostRecent() {
+		Iterator<V> iterator = values().iterator();
+		Object mostRecent=null;
+		while (iterator.hasNext()) {
+			 mostRecent = iterator.next();
+			
+		}
+		return mostRecent;
+	}
+}

Modified: branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/PortletStateHolder.java
===================================================================
--- branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/PortletStateHolder.java	2008-01-29 21:57:02 UTC (rev 5722)
+++ branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/PortletStateHolder.java	2008-01-29 22:50:36 UTC (rev 5723)
@@ -33,7 +33,6 @@
 
 import org.ajax4jsf.portlet.AjaxFacesPortlet;
 import org.ajax4jsf.portlet.context.AbstractExternalContext;
-import org.ajax4jsf.util.LRUMap;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 




More information about the richfaces-svn-commits mailing list