Hi.
I've created a patch and attached it to the RFE. There was a little
complication, because PageMap needs getRemoveValue(), which is only
found in MostRecentlyUsedMap. So I had to introduce new interface -
IMostRecentlyUsedMap.
So please have a look at the patch. If the interface is a showstopper, I
can survive it. I'll just have to use a patched version of wicket ;)
-Matej
Eelco Hillenius wrote:
Could you supply a patch please?
Eelco
Matej Knopp wrote:
Hi.
I know that there's not a lot of interest in this :)
but I just wonder if anyone actually objects, if this functionality
would be introducted to wicket.
Basicaly, it would allow to specify own MostRecentlyUsedPageMap instance.
class Application
{
...
public Map newMostRecentlyUsedMap()
{
return new MostRecentlyUsedMap(
getSettings().getMaxPages());
}
..
}
class PageMap
{
...
private transient Map pages;
...
private final Map getPages()
{
if (this.pages == null)
{
this.pages = session.getApplication()
.newMostRecentlyUsedMap();
}
return this.pages();
}
...
}
I think It's not exposing any internal class to user, it merely allows
user to create his own most recently used map, in which he can have
more control about which pages become stale.
Of course, this wouldn't affect any existing wicket application.
-Matej
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle
Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing
& QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop
Index: wicket/Application.java
===================================================================
RCS file: /cvsroot/wicket/wicket/src/java/wicket/Application.java,v
retrieving revision 1.66
diff -u -r1.66 Application.java
--- wicket/Application.java 11 Aug 2005 23:19:19 -0000 1.66
+++ wicket/Application.java 13 Aug 2005 20:07:41 -0000
@@ -37,6 +37,8 @@
import wicket.markup.html.image.resource.DefaultButtonImageResourceFactory;
import wicket.markup.parser.XmlPullParser;
import wicket.model.IModel;
+import wicket.util.collections.IMostRecentlyUsedMap;
+import wicket.util.collections.MostRecentlyUsedMap;
import wicket.util.convert.ConverterFactory;
import wicket.util.convert.IConverterFactory;
import wicket.util.crypt.ICrypt;
@@ -554,4 +556,15 @@
}
}
}
+
+ /**
+ * Factory method for creating a map for most recently used pages.
+ *
+ * @return A newly created map for holding most recently used pages.
+ */
+ public IMostRecentlyUsedMap newMostRecentlyUsedMap()
+ {
+ // default implementation
+ return new MostRecentlyUsedMap(getSettings().getMaxPages());
+ }
}
Index: wicket/PageMap.java
===================================================================
RCS file: /cvsroot/wicket/wicket/src/java/wicket/PageMap.java,v
retrieving revision 1.10
diff -u -r1.10 PageMap.java
--- wicket/PageMap.java 16 Jul 2005 14:28:32 -0000 1.10
+++ wicket/PageMap.java 13 Aug 2005 20:07:41 -0000
@@ -20,7 +20,7 @@
import java.io.Serializable;
import java.util.Iterator;
-import wicket.util.collections.MostRecentlyUsedMap;
+import wicket.util.collections.IMostRecentlyUsedMap;
/**
* THIS CLASS IS NOT PART OF THE WICKET PUBLIC API. DO NOT ATTEMPT TO USE IT.
@@ -44,7 +44,7 @@
private int pageId = 0;
/** The still-live pages for this user session. */
- private transient MostRecentlyUsedMap pages;
+ private transient IMostRecentlyUsedMap pages;
/** The session where this PageMap resides */
private transient Session session;
@@ -174,7 +174,7 @@
*/
final Page put(final Page page)
{
- MostRecentlyUsedMap pages = getPages();
+ IMostRecentlyUsedMap pages = getPages();
pages.put(page.getId(), page);
return (Page)pages.getRemovedValue();
}
@@ -240,12 +240,11 @@
/**
* @return MRU map of pages
*/
- private final MostRecentlyUsedMap getPages()
+ private final IMostRecentlyUsedMap getPages()
{
if (this.pages == null)
{
- this.pages = new
MostRecentlyUsedMap(session.getApplication().getSettings()
- .getMaxPages());
+ this.pages =
session.getApplication().newMostRecentlyUsedMap();
}
return this.pages;
}
Index: wicket/util/collections/MostRecentlyUsedMap.java
===================================================================
RCS file:
/cvsroot/wicket/wicket/src/java/wicket/util/collections/MostRecentlyUsedMap.java,v
retrieving revision 1.11
diff -u -r1.11 MostRecentlyUsedMap.java
--- wicket/util/collections/MostRecentlyUsedMap.java 19 May 2005 15:51:47
-0000 1.11
+++ wicket/util/collections/MostRecentlyUsedMap.java 13 Aug 2005 20:07:42
-0000
@@ -26,7 +26,7 @@
*
* @author Jonathan Locke
*/
-public class MostRecentlyUsedMap extends LinkedHashMap
+public class MostRecentlyUsedMap extends LinkedHashMap implements
IMostRecentlyUsedMap
{
/** Value most recently removed from map */
Object removedValue;
Index: wicket/util/collections/IMostRecentlyUsedMap.java
===================================================================
RCS file: wicket/util/collections/IMostRecentlyUsedMap.java
diff -N wicket/util/collections/IMostRecentlyUsedMap.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ wicket/util/collections/IMostRecentlyUsedMap.java 1 Jan 1970 00:00:00
-0000
@@ -0,0 +1,16 @@
+package wicket.util.collections;
+
+import java.util.Map;
+
+/**
+ * Interface that must be implemented by any map that will hold
+ * references to recently used pages.
+ * @author Matej Knopp
+ */
+public interface IMostRecentlyUsedMap extends Map
+{
+ /**
+ * @return Returns the last removed item.
+ */
+ public Object getRemovedValue();
+}