Updated Branches:
  refs/heads/master 3d26e5772 -> 0460a8d56

WICKET-5164 use HttpSessionBindingListener to be able to pass the
initial sessionId to the PageStore on expiry of the session

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/0460a8d5
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/0460a8d5
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/0460a8d5

Branch: refs/heads/master
Commit: 0460a8d56fc323b5c302ea6c4666af58a3fcc26f
Parents: 3d26e57
Author: svenmeier <[email protected]>
Authored: Tue Jul 9 13:11:19 2013 +0200
Committer: svenmeier <[email protected]>
Committed: Tue Jul 9 13:11:19 2013 +0200

----------------------------------------------------------------------
 .../apache/wicket/page/PageStoreManager.java    | 29 +++++++++++++++++---
 1 file changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/0460a8d5/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java 
b/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java
index cce5fed..9ae338b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java
+++ b/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java
@@ -25,6 +25,9 @@ import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.http.HttpSessionBindingListener;
+
 import org.apache.wicket.pageStore.IPageStore;
 
 /**
@@ -59,8 +62,8 @@ public class PageStoreManager extends AbstractPageManager
 
                if (managers.containsKey(applicationName))
                {
-                       throw new IllegalStateException("Manager for 
application with key '" + applicationName +
-                               "' already exists.");
+                       throw new IllegalStateException("Manager for 
application with key '" + applicationName
+                               + "' already exists.");
                }
                managers.put(applicationName, this);
        }
@@ -71,12 +74,18 @@ public class PageStoreManager extends AbstractPageManager
         * 
         * @author Matej Knopp
         */
-       private static class SessionEntry implements Serializable
+       private static class SessionEntry implements Serializable, 
HttpSessionBindingListener
        {
                private static final long serialVersionUID = 1L;
 
                private final String applicationName;
 
+               /**
+                * The id handed to the {@link IPageStore} to identify the 
session.
+                * <p>
+                * Note: If the container changes a session's id, this field 
remains unchanged on its
+                * initial value.
+                */
                private final String sessionId;
 
                private transient List<IManageablePage> sessionCache;
@@ -281,6 +290,18 @@ public class PageStoreManager extends AbstractPageManager
                                afterReadObject.add(page);
                        }
                }
+
+               @Override
+               public void valueBound(HttpSessionBindingEvent event)
+               {
+               }
+
+               @Override
+               public void valueUnbound(HttpSessionBindingEvent event)
+               {
+                       // WICKET-5164 use the original sessionId
+                       getPageStore().unbind(this.sessionId);
+               }
        }
 
        /**
@@ -411,7 +432,7 @@ public class PageStoreManager extends AbstractPageManager
        @Override
        public void sessionExpired(String sessionId)
        {
-               pageStore.unbind(sessionId);
+               // nothing to do, the SessionEntry will listen for it to become 
unbound by itself
        }
 
        /**

Reply via email to