Repository: wicket
Updated Branches:
  refs/heads/master a96a9cc4e -> d8206a23c


WICKET-6358 Possibility for each browser tab to have independent wicket session

Introduce overrideable methods for setting and getting the Wicket Session in 
HttpSession


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

Branch: refs/heads/master
Commit: d8206a23ca79ca66b3b9a0e53e2ccfe854b94b16
Parents: a96a9cc
Author: Martin Tzvetanov Grigorov <[email protected]>
Authored: Thu May 11 23:23:11 2017 +0200
Committer: Martin Tzvetanov Grigorov <[email protected]>
Committed: Thu May 11 23:23:11 2017 +0200

----------------------------------------------------------------------
 .../apache/wicket/session/HttpSessionStore.java | 32 +++++++++++++++++---
 1 file changed, 27 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/d8206a23/wicket-core/src/main/java/org/apache/wicket/session/HttpSessionStore.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/session/HttpSessionStore.java 
b/wicket-core/src/main/java/org/apache/wicket/session/HttpSessionStore.java
index fe95be8..e859a2f 100644
--- a/wicket-core/src/main/java/org/apache/wicket/session/HttpSessionStore.java
+++ b/wicket-core/src/main/java/org/apache/wicket/session/HttpSessionStore.java
@@ -88,7 +88,7 @@ public class HttpSessionStore implements ISessionStore
        @Override
        public final void bind(final Request request, final Session newSession)
        {
-               if (getAttribute(request, Session.SESSION_ATTRIBUTE_NAME) != 
newSession)
+               if (getWicketSession(request) != newSession)
                {
                        // call template method
                        onBind(request, newSession);
@@ -107,7 +107,7 @@ public class HttpSessionStore implements ISessionStore
                                        new 
SessionBindingListener(applicationKey, newSession));
 
                                // register the session object itself
-                               setAttribute(request, 
Session.SESSION_ATTRIBUTE_NAME, newSession);
+                               setWicketSession(request, newSession);
                        }
                }
        }
@@ -115,14 +115,14 @@ public class HttpSessionStore implements ISessionStore
        @Override
        public void flushSession(Request request, Session session)
        {
-               if (getAttribute(request, Session.SESSION_ATTRIBUTE_NAME) != 
session)
+               if (getWicketSession(request) != session)
                {
                        // this session is not yet bound, bind it
                        bind(request, session);
                }
                else
                {
-                       setAttribute(request, Session.SESSION_ATTRIBUTE_NAME, 
session);
+                       setWicketSession(request, session);
                }
        }
 
@@ -172,12 +172,34 @@ public class HttpSessionStore implements ISessionStore
                String sessionId = getSessionId(request, false);
                if (sessionId != null)
                {
-                       return (Session)getAttribute(request, 
Session.SESSION_ATTRIBUTE_NAME);
+                       return getWicketSession(request);
                }
                return null;
        }
 
        /**
+        * Reads the Wicket {@link Session} from the {@link HttpSession}'s 
attribute
+        *
+        * @param request The Wicket request
+        * @return The Wicket Session or {@code null}
+        */
+       protected Session getWicketSession(final Request request)
+       {
+               return (Session) getAttribute(request, 
Session.SESSION_ATTRIBUTE_NAME);
+       }
+
+       /**
+        * Stores the Wicket {@link Session} in an attribute in the {@link 
HttpSession}
+        *
+        * @param request The Wicket request
+        * @param session The Wicket session
+        */
+       protected void setWicketSession(final Request request, final Session 
session)
+       {
+               setAttribute(request, Session.SESSION_ATTRIBUTE_NAME, session);
+       }
+
+       /**
         * Template method that is called when a session is being bound to the 
session store. It is
         * called <strong>before</strong> the session object itself is added to 
this store (which is
         * done by calling {@link ISessionStore#setAttribute(Request, String, 
Serializable)} with key

Reply via email to